Python socket.SIO_RCVALL() Examples

The following are code examples for showing how to use socket.SIO_RCVALL(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: icmp-remote-shell   Author: alex-kostirin   File: server.py    MIT License 5 votes vote down vote up
def main():
    args = parse_args()
    host = args.host
    ping_delay = args.ping_delay
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
    s.bind((host, 0))
    s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
    #  s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
    print("Server Started......")
    while True:
        # while 1:
        data = s.recvfrom(65565)
        d1 = data[0]
        if bytearray(d1)[20] != ICMP_ECHO_REQUEST_TYPE:
            continue
        d1 = str(d1)
        data1 = re.search('@@(.*)', d1)
        command = data1.group(0)
        cmd = command[2:len(command) - 1]
        d = data[1]
        d1 = str(d)
        ip = d1[2:-5]
        # print ip
        print(cmd)  # Holding the command to execute
        print(ip)  # Holding the destination address to send the ping
        output = execute(cmd)
        for line in output.readlines():
            send_one(ip, ping_delay, line) 
Example 2
Project: scapy   Author: secdev   File: native.py    GNU General Public License v2.0 5 votes vote down vote up
def close(self):
        if not self.closed and self.promisc:
            self.ins.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
        super(L3WinSocket, self).close() 
Example 3
Project: Offensive-Security-Certified-Professional   Author: StevenDias33   File: host-scanner-via-udp.py    MIT License 5 votes vote down vote up
def main(argv):
    global BIND

    if len(argv) < 3:
        print('Usage: ./udp-scan.py <bind-ip> <target-subnet>')
        sys.exit(1)

    bindAddr = sys.argv[1]
    subnet = sys.argv[2]

    sockProto = None
    if os.name == 'nt':
        sockProto = socket.IPPROTO_IP
    else:
        sockProto = socket.IPPROTO_ICMP

    sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, sockProto)
    if DEBUG: print('[.] Binding on {}:0'.format(bindAddr))
    sniffer.bind((bindAddr, 0))

    # Include IP headers in the capture
    sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

    # In Windows, set up promiscous mode.
    if os.name == 'nt':
        try:
            sniffer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
        except socket.error, e:
            print('[!] Could not set promiscous mode ON: "{}"'.format(str(e)))

    # Sending thread