Skip to content

Commit 2f245f1

Browse files
authored
Merge pull request #364 from TaniaMalhotra/banner
banner script added
2 parents ffbdd82 + 9003ac4 commit 2f245f1

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Python/banner/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Banner grabber
2+
- - - - - -
3+
# Aim
4+
A Banner is like a text message received from the host. It contains information about the services running on the host along with information about the ports. </br>
5+
Here I've used some common ports like </br>
6+
- 20/21: FTP
7+
- 22: SSH(Secure Shell)
8+
- 23: Telnet
9+
- 25: SMTP
10+
- 80: HTTP
11+
- 156: SQL Server
12+
- 443: HTTPS
13+
14+
# Output
15+
Banner info includes</br>
16+
- Type of request
17+
- Content-type
18+
- Content-length
19+
- Date
20+
- Referrer-policy
21+
22+
![alt-text](https://github.com/TaniaMalhotra/hacking-tools-scripts/blob/banner/Python/banner/Screenshot%20(591).png)

Python/banner/Screenshot (591).png

86.3 KB
Loading

Python/banner/banner.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import socket
2+
from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM
3+
def scan_ports(name, port):
4+
sock = socket.socket(AF_INET, SOCK_STREAM)
5+
try:
6+
#connect to the port
7+
sock.connect((name,port))
8+
sock.send(b'200 OK\r\n')
9+
# accepting banner as ascii string
10+
banner = str(sock.recv(256), 'ascii')
11+
# printing status portwise
12+
print("[+] {port}/tcp is open".format_map(vars()))
13+
# printing banner
14+
print("- Banner")
15+
print(banner)
16+
except:
17+
# if port is filtered or closed
18+
print("{port} is filtered/closed/timedout".format_map(vars()))
19+
20+
def main():
21+
target_host = input("Please enter the target host. For eg. www.example.com ")
22+
# listing common ports for convenience
23+
target_ports = [22, 25, 53, 80, 443]
24+
socket.setdefaulttimeout(5)
25+
# selecting one port a time
26+
for port in target_ports:
27+
scan_ports(target_host, port)
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)