Skip to content

Commit 8c9dccb

Browse files
authored
Add proxy handling in UI
1 parent b91e5d9 commit 8c9dccb

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

hacklib.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def login(self, url, username, password):
134134
# ascertain the type of login page given by url
135135
logintype = self. _get_login_type()
136136
if logintype == 'BA':
137-
# attempts to login with BA method and return True
137+
# attempts to login with BA method and return html
138138
return self._login_BA()
139139
if logintype == 'TO':
140140
raise Exception('Request timed out.')
@@ -279,8 +279,8 @@ class Proxy(object):
279279
'''Can work in conjunction with getProxies() to tunnel all
280280
network activity in the Python script through a Socks4/5 proxy.
281281
Commands:
282-
set_auto() Args: getProxies(), timeout=10
283-
set_manual() Args: IP, port, proxy_type
282+
connect() Args: getProxies(), timeout=10
283+
connect_manual() Args: IP, port, proxy_type
284284
'''
285285

286286
def __init__(self):
@@ -405,3 +405,42 @@ def topPasswords(amount):
405405
passlist = urllib2.urlopen(url).read().split('\n')
406406
return passlist[:amount]
407407

408+
def userInterface():
409+
'''Start text-based interface for easier usage if hacklib isn't being used as a library.
410+
'''
411+
while True:
412+
print 'Enter an IP address or URL for further options.'
413+
print 'Or, enter "proxy" to connect to a proxy.'
414+
cmd = raw_input('> ')
415+
if '.' in cmd: # Checks for . to make sure it's an IP or URL
416+
address = getIP(cmd)
417+
print 'What would you like to do?'
418+
print '1) PortScan'
419+
print '2) DOS'
420+
print '3) Send TCP message'
421+
print '4) Attempt login'
422+
cmd = getIP(raw_input('> '))
423+
elif 'proxy' in cmd:
424+
print 'Would you like to automatically find a proxy or input one manually?'
425+
print 'Enter the number corresponding to your choice.'
426+
print '1) Auto'
427+
print '2) Manual'
428+
cmd = raw_input('> ')
429+
proxies = getProxies()
430+
global proxy
431+
proxy = Proxy()
432+
if cmd == '1':
433+
proxy.connect(getProxies())
434+
print 'Your new IP address is ' + proxy.IP
435+
print 'This proxy is located in ' + proxy.country
436+
elif cmd == '2':
437+
pr_address = raw_input('Proxy address > ')
438+
pr_port = raw_input('Proxy port > ')
439+
pr_type = raw_input('Enter "Socks4" or "Socks5" > ')
440+
try: proxy.connect_manual(pr_address, pr_port, pr_type)
441+
except: print 'Connection failed.'; pass
442+
print 'Proxy connected.'
443+
pass
444+
445+
if __name__ == '__main__':
446+
userInterface()

0 commit comments

Comments
 (0)