-
Notifications
You must be signed in to change notification settings - Fork 2
/
bancolombia.rb
49 lines (44 loc) · 1.69 KB
/
bancolombia.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "mechanize"
require "yaml"
require 'highline/import'
begin
puts "Config file detected"
yml = YAML::load(File.open('config.yml'))
username = yml["username"]
password = yml["password"]
rescue Exception
puts "No config file to read."
username = ask("Enter your bancolombia username: ")
password = ask("Enter your 4 digits bancolombia password: ") { |q| q.echo = "*" }
end
##Login username page
agent = Mechanize.new
agent.get("https://bancolombia.olb.todo1.com/olb/Init")
userLoginPage = agent.get("https://bancolombia.olb.todo1.com/olb/Login")
userLoginPage.form_with(:name => "authenticationForm") do |f|
f.userId = username
end.click_button
##Redirect to password page
passwordPage = agent.get("https://bancolombia.olb.todo1.com/olb/GetUserProfile")
passwordPageHtml = passwordPage.body
##Insert \r for correct regex on password scripts
passwordPageHtml.gsub!(/document.getElementById/, "\r\n\t document.getElementById")
enc_password = ""
password.to_s.split('').each do |n|
passwordPageHtml.match(/\'td_#{n}\'\)\.addEventListener\(\'click\'\,\sfunction\(\)\{\S*\(\"(.*)\"\)\;\}/);
enc_password << $1
end
##Capture secret hidden field
passwordPageHtml.match(/'PASSWORD\':\'(.*)\'/)
secretHiddenField = $1
##Post encripted password and secret hidden field
passwordPage.form_with(:name => "authenticationForm") do |f|
f.userId = "0"
f.password = enc_password
f.add_field!(secretHiddenField, value = enc_password)
end.click_button
##Get Balance
agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
balance = balancePage.search(".contentTotalNegrita").last.children.text
puts "Your actual balance is: $#{balance}"