Raw Socket Python Application deployed httpd - python

I have an python flask application that deployed httpd.
And in this application, I am sending syn packet and calculating response time.
I am using scapy to send syn packet.
So Issue is;
Scapy uses raw socket to send packet but raw socket can open by root user :(
So, httpd run as other user and raises exception that "Operation not permitted".
I already tried that,
setcap cap_net_admin,cap_net_raw=eip /usr/sbin/httpd
But still raises exception that 'Operation not permitted'
Best regards..

Instead of using that what you can do is just open up Command line if your on windows as admin and then run the script and it should work fine

Related

python FTP works in Linux but I get WinError 10060 in Windows - server is up

The following code works flawlessly in Linux, retrieving the list of folders/files available in the FTP server:
from ftplib import FTP
server = FTP('ftp.ibge.gov.br')
server.connect()
server.login()
server.nlst()
However, in Windows 10, I get the server welcome message after connect() and the '230 login successful" message, but when I try to send any command to the server - like server.nlst() or server.dir() - socket.py raises a TimeoutError [WinError 10060]
I am 100% sure that the server is up, and in Linux server.nlst() retrieves the information fast as lightning - so, it is not a "true" timeout error, if I set timeout=1000, or larger, I get the same error.
What is wrong?
An explanation of the problem can be found here: passive reply with unroutable address
It seems that 'ftp.ibge.gov.br' is not properly configured.
Luckily, I found a working solution.
However, it seems that ftplib is not able to handle this problem in Windows only. With Linux, I have been accessing files from this server for years using ftplib

socket recv hangs forever or timeout

I'm using rpyc package to communicate between server and client. Everything was worked fine until today. My client pc can't receive message from server. So I run socket server:
$ python bin/rpyc_classic.py
INFO:SLAVE/18812:server started on [0.0.0.0]:18812
Connect like in docs:
import rpyc
conn = rpyc.classic.connect("10.99.100.200")
I tried to debug with wireshark, firewall is off and all is worked before. I'm using OSX. When I do reverse, connection working fine

Run nping through proxy server ubuntu

I am working on developing a Python program to ping websites through TCP. I used nping to ping websites through TCP continuously for a certain period of time, and it works great. After that, I added a proxy server option in the code to make nping work even through proxy server.
Next I installed a Squid proxy server and configured successfully. Now my problem is that nping works even with proxy server without any proxy authentication. I accessed the nping command in terminal, and it works, but other commands such as sudo apt-get update stop and show "proxy authentication required". Why is nping working even with proxy server enabled?
I read several articles and found that ping transfers ICMP packets, so it can't be blocked through proxy server. But nping send TCP packets, so why is it not getting blocked by the proxy server?

Python server with library socket

Im trying to build a python application that will be run on a specific port so that when i try to connect on that port the python application will be run.
Im guessing i have to do that with socket library but im not very sure about that.
On Linux you can do this with xinetd. You edit /etc/services to give a name to your port, then add a line to /etc/xinetd.conf to run your server when someone connects to that service. The TCP connection will be provide to the Python script as its standard input and output.

How to connect to ssh server from another server

I've been trying to connect to first an out-of-band management server (in my case, since I'm connecting to DELL-servers, an iDRAC) and through that connect to the main server itself. I've got it to work when I do it manually, using, in the (windows) terminal:
putty.exe -ssh 'username'#'iDRAC-IP'
followed by PuTTY window opening where I type in the password, followed by
connect
which connects to the server itself, and then I type in the username and password for the server, completing the process.
When I've been writing my script in python, I'm using paramiko, http://www.paramiko.org/, suggested here on stackoverflow, and following this example: https://www.ivankrizsan.se/2016/04/24/execute-shell-commands-over-ssh-using-python-and-paramiko/, and it works just splendid for the iDRAC (the first server I connect to). It also works when I type in
stdin, stdout, stderr = ssh_client.exec_command('connect')
because I am still in my first server (ssh_client) (I can tell this is working because when I try to connect to the server manually afterwards, it is occupied). But after that it stops working, since when doing 'connect' I am no longer in ssh_client, but in a different server.
So my question is - how do I connect to a server from another server (in this case being the out-of-band management server) and log in to this one?
You can use ssh tunnel to do so.
this post may resolve your problem:
PyCharm: Configuring multi-hop remote Interpreters via SSH

Categories