Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdd29fc

Browse files
committed
dependencies installer
1 parent 230d4fb commit bdd29fc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

hacklib.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ def getProxies(country_filter = 'ALL', proxy_type = ('Socks4', 'Socks5')):
445445
proxy_type: Specify whic Socks version to use, e.g. 'Socks5'
446446
'''
447447
try: import mechanize
448-
except: raise MissingPackageException('Please install the mechanize module before continuing.')
448+
except: raise MissingPackageException('Please install the mechanize module before continuing. Use hacklib.installDependencies()')
449449
try: from bs4 import BeautifulSoup
450-
except: raise MissingPackageException('Please install the beautifulsoup4 module before continuing.')
450+
except: raise MissingPackageException('Please install the beautifulsoup4 module before continuing. Use hacklib.installDependencies()')
451451
br = mechanize.Browser()
452452
br.set_handle_robots(False)
453453
br.addheaders = [('User-agent', 'googlebot')]
@@ -478,6 +478,18 @@ def getProxies(country_filter = 'ALL', proxy_type = ('Socks4', 'Socks5')):
478478
proxylist = filteredlist
479479
return proxylist
480480

481+
def installDependencies():
482+
import subprocess
483+
try:
484+
mech = subprocess.check_output(['/usr/local/bin/pip', 'install', 'mechanize'])
485+
if 'successfully installed' in mech: print 'Installed mechanize'
486+
beaut = subprocess.check_output(['/usr/local/bin/pip', 'install', 'bs4'])
487+
if 'successfully installed' in beaut: print 'Installed beautifulsoup'
488+
scapy = subprocess.check_output(['/usr/local/bin/pip', 'install', 'scapy'])
489+
if 'successfully installed' in beaut: print 'Installed scapy'
490+
except:
491+
raise MissingPipException('Could not find pip.')
492+
481493
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
482494
def send(IP, port, message, keepalive = False):
483495
'''Creates new socket and sends a TCP message. If keepalive is true, use hacklib.sock
@@ -707,3 +719,6 @@ def userInterface():
707719

708720
class MissingPackageException(Exception):
709721
'''Raise when 3rd party modules are not able to be imported.'''
722+
723+
class MissingPipexception(Exception):
724+
'''Raise when pip is not able to be found'''

0 commit comments

Comments
 (0)