Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Python/banner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Banner grabber
- - - - - -
# Aim
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>
Here I've used some common ports like </br>
- 20/21: FTP
- 22: SSH(Secure Shell)
- 23: Telnet
- 25: SMTP
- 80: HTTP
- 156: SQL Server
- 443: HTTPS

# Output
Banner info includes</br>
- Type of request
- Content-type
- Content-length
- Date
- Referrer-policy

![alt-text](https://github.com/TaniaMalhotra/hacking-tools-scripts/blob/banner/Python/banner/Screenshot%20(591).png)
Binary file added Python/banner/Screenshot (591).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Python/banner/banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import socket
from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM
def scan_ports(name, port):
sock = socket.socket(AF_INET, SOCK_STREAM)
try:
#connect to the port
sock.connect((name,port))
sock.send(b'200 OK\r\n')
# accepting banner as ascii string
banner = str(sock.recv(256), 'ascii')
# printing status portwise
print("[+] {port}/tcp is open".format_map(vars()))
# printing banner
print("- Banner")
print(banner)
except:
# if port is filtered or closed
print("{port} is filtered/closed/timedout".format_map(vars()))

def main():
target_host = input("Please enter the target host. For eg. www.example.com ")
# listing common ports for convenience
target_ports = [22, 25, 53, 80, 443]
socket.setdefaulttimeout(5)
# selecting one port a time
for port in target_ports:
scan_ports(target_host, port)


if __name__ == "__main__":
main()