networking

How to fix: TypeError: filter expected 2 arguments, got 1

How to fix: TypeError: filter expected 2 arguments, got 1 Question: I am making a browser using python and PyQt5/PySide6. I implemented an adblock which uses a list to block ads from opening as tabs. ` class WebPage(QWebEnginePage): adblocker = filter(open(os.path.join("build files", "adlist.txt"), encoding="utf8")) def __init__(self, parent=None): super().__init__(parent) def acceptNavigationRequest(self, url, _type, isMainFrame): urlString = …

Total answers: 1

dhcp server including dhcp discover,offer,request,ack problem

dhcp server including dhcp discover,offer,request,ack problem Question: this is my dhcp server: import socket from scapy.all import * from scapy.layers.dhcp import BOOTP, DHCP from scapy.layers.inet import UDP, IP from scapy.layers.l2 import Ether def dhcp_server(): # Server parameters server_ips = [‘127.0.0.1’] server_port = 67 # Create a UDP socket for DHCP communication dhcp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) …

Total answers: 2

How to make tcpClient not receive multiple message per each conn.sendall()?

How to make tcpClient not receive multiple message per each conn.sendall()? Question: Python server sender side: soc = socket.socket() hostname="localhost" port=8000 soc.bind((hostname,port)) soc.listen(1) conn , addr = soc.accept() print("device connected") cc = 0 cap = cv2.VideoCapture(0) with mp_hollistic.Holistic(static_image_mode = True ,min_detection_confidence=0.7, min_tracking_confidence=0.7) as holistic: while cap.isOpened(): ret, frame = cap.read() res, f = func(frame) val …

Total answers: 1

How to add domain name in DHCP offer packet with scapy?

How to add domain name in DHCP offer packet with scapy? Question: I have written a DHCP server code in python using Scapy that can sniff discovery messages and send an appropriate offer message with an IP for a client. I tried to insert another option in the packet regarding the DNS server IP, but …

Total answers: 1

Find connected components recursively in a data frame

Find connected components recursively in a data frame Question: Consider the following data frame: import numpy as np import pandas as pd df = pd.DataFrame( { "main": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "component": [ [1, 2], [np.nan], [3, 8], [np.nan], [1, 5, 6], [np.nan], [7], [np.nan], [9, 10], [np.nan], …

Total answers: 1

Grabbing large UDP messages in python

Grabbing large UDP messages in python Question: I have a sensor that sends a 35336 byte long message 16 times per second via UDP, as well as several messages under 800 bytes. The messages are seen clearly in Wireshark and arrive at close to the expected rate. When trying to use a python script to …

Total answers: 2

Unable to print TCPcump information using python subprocess

Unable to print TCPcump information using python subprocess Question: I wanted to process tcpdump output in a python script and so far I was able to get to this implementation from subprocess import Popen, PIPE, CalledProcessError import os import signal import time if __name__=="__main__": cmd = ["sudo","tcpdump", "-c","1000","-i","any","port","22","-n"] with Popen(cmd, stdout=PIPE, bufsize=1, universal_newlines=True) as p: …

Total answers: 1

How are these values calculated in Python Scapy?

How are these values calculated in Python Scapy? Question: I am curious about the values of the chksum and how it is calculated. ###[ IP ]### chksum = 0x95d3 ###[ UDP ]### chksum = 0x1a77 What is chksum=0x1a77 and chksum=0x95d3 how are they calculated in python Scapy? I need some explanation for these values. Asked …

Total answers: 1

Visually see edges and node color in networkx graph

Visually see edges and node color in networkx graph Question: I am creating a graph that will represent a Fat Tree (https://www.researchgate.net/figure/Fat-Tree-structure-with-n-4-It-has-three-levels-of-switches_fig1_220429211). Currently, when I visually see the network I code up, the nodes are close together but I do not see a visible edge between them. How do I make my nodes not be …

Total answers: 1

Why does this proxy require authentication when used from curl but not from python requests?

Why does this proxy require authentication when used from curl but not from python requests? Question: I’m using https://github.com/abhinavsingh/proxy.py, setting it up with basic auth like so: proxy –basic-auth "user:pass" When I use it with curl, it requires proxy auth as expected: curl -I -x localhost:8899 http://example.com => 407 curl -I -x user:pass@localhost:8899 http://example.com => …

Total answers: 1