You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's some useful addition that allow to use proxy in SSH login process.
try:
importsocks#importing SocksiPy library that allow use proxy (http://socksipy.sourceforge.net)exceptImportError:
notfound.append('socksipy')
#Modified SSH_login classclassSSH_login:
'''Brute-force SSH'''usage_hints= (
"""%prog host=10.0.0.1 user=root password=FILE0 0=passwords.txt -x ignore:mesg='Authentication failed.'""",
)
available_options= (
('host', 'target host'),
('port', 'target port [22]'),
('user', 'usernames to test'),
('password', 'passwords to test'),
('auth_type', 'type of password authentication to use [password|keyboard-interactive|auto]'),
('keyfile', 'file with RSA, DSA or ECDSA private key to test'),
#Proxy options
('proxy_type', 'type of the proxy server [SOCKS4|SOCKS5|HTTP]'),
('proxy_addr', 'IP address or DNS name of the proxy server'),
('proxy_port', 'port of the proxy server [1080 for socks|8080 for http]'),
('proxy_rdns', 'boolean flag than modifies the behavior regarding DNS resolving (if True, DNS resolving will be \ preformed remotely (Socks4a, Socks5, HTTP) [True]'),
('proxy_username', 'for Socks5 servers this allows simple username / password authentication, for Socks4 servers, \ this parameter will be sent as the userid, ignored if an HTTP server is being used'),
('proxy_password', 'parameter is valid only for Socks5 servers and specifies the respective password for the \ username provided')
)
available_options+=TCP_Cache.available_optionsResponse=Response_Base# connect method take some addition attributes for proxyingdefconnect(self, host, port, user, proxy_type=None, proxy_addr=None, proxy_port=None, proxy_rdns=True,
proxy_username=None, proxy_password=None):
# Replace paramiko socket with socksipy object if proxy is defined.ifproxy_typeandproxy_addrisnotNone:
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4ifproxy_type.upper() =='SOCKS4'elsesocks.PROXY_TYPE_SOCKS5ifproxy_type.upper() =='SOCKS5'elsesocks.PROXY_TYPE_HTTP, proxy_addr, int(proxy_port),
proxy_rdns, proxy_username, proxy_password)
paramiko.client.socket.socket=socks.socksocketfp=paramiko.Transport('%s:%s'% (host, int(port)))
fp.start_client()
returnTCP_Connection(fp, fp.remote_version)
defexecute(self, host, port='22', user=None, password=None, auth_type='password', keyfile=None, persistent='1',
**proxy_params): #Proxy parameters sent thorough execute() method in **kwargswithTiming() astiming:
fp, banner=self.bind(host, port, user, **proxy_params)
try:
ifuserisnotNone:
ifkeyfileisnotNone:
key=load_keyfile(keyfile)
withTiming() astiming:
ifkeyfileisnotNone:
fp.auth_publickey(user, key)
elifpasswordisnotNone:
ifauth_type=='password':
fp.auth_password(user, password, fallback=False)
elifauth_type=='keyboard-interactive':
fp.auth_interactive(user, lambdaa,b,c: [password] iflen(c) ==1else [])
elifauth_type=='auto':
fp.auth_password(user, password, fallback=True)
else:
raiseNotImplementedError("Incorrect auth_type '%s'"%auth_type)
logger.debug('No error')
code, mesg='0', bannerself.reset()
exceptparamiko.AuthenticationExceptionase:
logger.debug('AuthenticationException: %s'%e)
code, mesg='1', str(e)
ifpersistent=='0':
self.reset()
returnself.Response(code, mesg, timing)
The text was updated successfully, but these errors were encountered:
There's some useful addition that allow to use proxy in SSH login process.
The text was updated successfully, but these errors were encountered: