-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created simple vuln scanner to learn python
- Loading branch information
root
committed
Oct 27, 2017
1 parent
e743250
commit 3653a3e
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import socket | ||
import os | ||
import sys | ||
|
||
def retBanner(ip, port): | ||
try: | ||
socket.setdefaulttimeout(2) | ||
s = socket.socket() | ||
s.connect((ip, port)) | ||
banner = s.recv(1024) | ||
return banner | ||
except: | ||
return | ||
def checkVulns(banner, filename): | ||
f = open(filename, 'r') | ||
for line in f.readlines(): | ||
if line.strip('\n') in banner: | ||
print '[+] Server is vulnerable: ' + banner.strip('\n') | ||
def main(): | ||
if len(sys.argv) == 2: | ||
filename = sys.argv[1] | ||
if not os.path.isfile(filename): | ||
print '[-] ' + filename + ' does not exist.' | ||
exit(0) | ||
if not os.access(filename, os.R_OK): | ||
print '[-] ' + filename + ' access denied.' | ||
exit(0) | ||
else: | ||
print '[-] Usage: ' + str(sys.argv[0]) + ' <vuln filename>' | ||
exit(0) | ||
portList = [21, 22, 25, 80, 110, 443] | ||
for x in range(147, 150): | ||
ip = '192.168.95.' + str(x) | ||
for port in portList: | ||
banner = retBanner(ip, port) | ||
if banner: | ||
print '[+] ' + ip + ': ' + banner | ||
checkVulns(banner, filename) | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test |