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
|
# File 'lib/instabot/login.rb', line 2
def login(username = '', password = '')
if @login_mode == :manual
username = username.to_s
password = password.to_s
else
username = options[:username]
password = options[:password]
end
log('trying to login', 'LOGIN')
puts '[+] '.cyan + "Trying to login as [#{username}]"
login_page = @agent.get('https://www.instagram.com/accounts/login/?force_classic_login')
page_form = login_page.forms.last
page_form.username = username
page_form.password = password
page = page_form.submit
if page.code == '200' && page.uri.to_s != 'https://www.instagram.com/accounts/login/?force_classic_login' && !page.uri.to_s.include?('challenge')
@login_status = true
log('successfully logged in', 'LOGIN')
puts '[+] '.cyan + 'Successfully logged in'.green.bold
else
@login_status = false
if page.uri.to_s.include?('challenge')
puts '[-] '.cyan + 'Your account needs veryfication or it has been banned from instagram'.red.bold
else
puts '[-] '.cyan + 'Invalid username or password'.red.bold
end
check_login_status
end
rescue Exception => e
log("an error detected: #{e.class} #{e} #{e.backtrace}", 'LOGIN')
@login_status = false
puts '[-] '.cyan + "#{e.class} #{e.message}\n check out the log file for full trace ".red
exit
end
|