0

Guys I'm using Kali Linux, I created a python script and everything is fine, but when I try to use a reserved port for this error:

PermissionError: [Errno 13] Permission denied

But when I use a higher port, 8080 for example, then it works, but I’m already logged in as root, and I’ve also given permission to my Python file with chmod + x script.py. The port I want to use is 443, can someone help me?

Edit:

My code:

import os
import sys                                        
importt platform                                   
import time
import socket
import argparse                                   
                                              
HOST = "localhost"                                
PORT = 443
                                              
def main():                                        
 try:
  print(f"Starting honeypot ...")                   
  time.sleep(5)
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)                                               
  s.bind((HOST,PORT))
  while True:
   s.listen(5)
   conn,addr = s.accept()                            
   print(f"Honeypot has been visited by: {addr[0]}")                                                   
   print(f"Honeypot has been visited by: {addr[1]}")
   conn.sendall(b"I got you!\n")
 except KeyboardInterrupt:
  print("\nShutdown honeypot ...")

main()

The idea is to build a honeypot

2
  • Show us your code and full error stacktrace. Use the Edit button.
    – gronostaj
    Mar 2, 2021 at 8:41
  • I already edited :)
    – Dakota
    Mar 2, 2021 at 12:14

1 Answer 1

0

You have probably another network service running (ex. apache2) on port 80, if you tried to bind on it.

sudo service apache2 stop

btw, dont use time.sleep(*) on your script python is already one of the slowest programming languages, and it does NOT help anything. the first error looks like you dont have enough permissions on user you ran this script with. use root next time if you listen something on your network? :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .