Skip to content

Commit d2320d2

Browse files
authored
Add files via upload
0 parents  commit d2320d2

File tree

8 files changed

+194
-0
lines changed

8 files changed

+194
-0
lines changed

banner_grab.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import socket
2+
3+
4+
def getBanner(ip, port):
5+
try:
6+
socket.setdefaulttimeout(1)
7+
sock = socket.socket()
8+
sock.connect((ip, port))
9+
banner = sock.recv(1024)
10+
return banner
11+
except:
12+
return
13+
14+
15+
def checkVulns(banner):
16+
print('Checking banners')
17+
for vuln_banner in open('vuln_banners.txt', 'r').readlines():
18+
print('Checking banner: ' + vuln_banner)
19+
if vuln_banner.strip('\n') in banner:
20+
print('[+] Vulnerability found: ' + vuln_banner)
21+
return
22+
23+
24+
def main():
25+
portList = [21, 22, 25, 80, 110, 443]
26+
for x in range(1, 33):
27+
ip = '192.168.1.' + str(x)
28+
for port in portList:
29+
print('Checking: ' + str(ip) + ':' + str(port))
30+
banner = getBanner(ip, port)
31+
if banner:
32+
print('[+] ' + ip + ': ' + banner)
33+
checkVulns(banner)
34+
35+
if __name__ == '__main__':
36+
main()

bottle_example.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from bottle import route, run, template
2+
3+
@route('/hello/<name>')
4+
def index(name):
5+
return template('<b>Hello {{name}}</b>!', name=name)
6+
7+
run(host='localhost', port=8080)

cgi_example.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python
2+
3+
# Import modules for CGI handling
4+
import cgi, cgitb
5+
6+
# Create instance of FieldStorage
7+
form = cgi.FieldStorage()
8+
9+
# Get data from fields
10+
first_name = form.getvalue('first_name')
11+
last_name = form.getvalue('last_name')
12+
13+
# Check box form fields (bool)
14+
if form.getvalue('box1'):
15+
# checked
16+
else:
17+
# not checked
18+
19+
print "Content-type:text/html\r\n\r\n"
20+
print "<html>"
21+
print "<head>"
22+
print "<title>Hello CGI Program</title>"
23+
print "</head>"
24+
print "<body>"
25+
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
26+
print "</body>"
27+
print "</html>"

echoserv.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
3+
from twisted.internet.protocol import Protocol, Factory
4+
from twisted.internet import reactor
5+
6+
### Protocol Implementation
7+
8+
# This is just about the simplest possible protocol
9+
class NanoBot(Protocol):
10+
def dataReceived(self, data):
11+
"""
12+
As soon as any data is received, write it back.
13+
"""
14+
self.transport.write(data)
15+
# process incoming data
16+
17+
def main():
18+
f = Factory()
19+
f.protocol = NanoBot
20+
reactor.listenTCP(8000, f)
21+
reactor.run()
22+
23+
if __name__ == '__main__':
24+
main()

http_get_with_cookies.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import requests
2+
3+
url = 'http://www.example.com'
4+
cookies = {'session': 'asdfasdf12341234'}
5+
6+
# User session to store response cookies for subsequent requests
7+
#session = requests.Session()
8+
#response = session.get(url, cookies=cookies)
9+
10+
# One shot request with cookies specified manually
11+
response = requests.get(url, cookies=cookies)
12+
13+
# Print response info
14+
print(response.text)
15+
print(response.cookies)

http_login.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests
2+
3+
postData = {
4+
'name': 'username',
5+
'pass': 'password',
6+
'form_id': 'user_login',
7+
'op': 'Log in'
8+
}
9+
10+
loginUrl = 'http://www.example.com/login'
11+
12+
session = requests.Session()
13+
response = session.post(loginUrl, data=postData)
14+
15+
print(response.text)
16+
print(response.headers)
17+
print(session.cookies)

ping_capture.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/python2
2+
3+
"""
4+
Captures a single ICMP ping packet
5+
"""
6+
7+
import socket
8+
import os
9+
10+
# Host to listen on
11+
host = "192.168.1.4"
12+
13+
# Create raw socket and bind
14+
if os.name == "nt":
15+
socket_protocol = socket.IPPROTO_IP
16+
else:
17+
socket_protocol = socket.IPPROTO_ICMP
18+
19+
sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket_protocol)
20+
21+
sniffer.bind((host, 0))
22+
23+
# Include IP headers in capture
24+
sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
25+
26+
# In windows need to send an IOCTL to set up listen mode
27+
if os.name == "nt":
28+
sniffer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
29+
30+
# Read single packet
31+
print sniffer.recvfrom(65565)
32+
33+
# Turn off listen mode in windows
34+
if os.name == "nt":
35+
sniffer.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
36+
37+
38+

socket.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import socket
2+
3+
class mysocket:
4+
5+
def __init__(self, sock=None):
6+
if sock is None:
7+
self.sock = socket.socket(
8+
socket.AF_INET, socket.SOCK_STREAM)
9+
else:
10+
self.sock = sock
11+
12+
def connect(self, host, port):
13+
self.sock.connect((host, port))
14+
15+
def mysend(self, msg):
16+
totalsent = 0
17+
while totalsent < MSGLEN:
18+
sent = self.sock.send(msg[totalsent:])
19+
if sent == 0:
20+
raise RuntimeError("socket connection broken")
21+
totalsent = totalsent + sent
22+
23+
def myreceive(self):
24+
msg = ''
25+
while len(msg) < MSGLEN:
26+
chunk = self.sock.recv(MSGLEN-len(msg))
27+
if chunk == '':
28+
raise RuntimeError("socket connection broken")
29+
msg = msg + chunk
30+
return msg

0 commit comments

Comments
 (0)