Im working on creating a Scapy script that does the three-way handshake, GET request, and then finally grabs the contents of a file via HTTP_request thats on a remote apache server, and then display it in the browser on my machine.
I've managed to get everything working except for when I try to do a HTTP Request it also returns that the file doesn't exist and then shows some random path its looking in.
This is the command ive been tinkering with thats on the scapy site that should work but doesnt:
load_layer("http")
http_request("10.10.10.10","/test", port=80, display=True)
the permissions of the files on the remote host are 777 just for testing
I can reach the web page via Firefox and it displays the file I'm looking for fine (this is just for testing as well)
Tried chrome as well and same issue occurred
information from this command comes back accurate when its without the path, but doesn't open the page either
The error below is the response I continuously get despite different versions of the command. The only difference is that the end of the URL string is different with every run.
i.e: this one is "BSVkz0.html" but the previous one was "WCU4c0.html"
Failed to open URL"file:///tmp/scapyWCU4cO.html".
Error when getting information for file "tmp/scapyBSVkz0.html": No such file or directory.
More info:
played around with it more and received a new error in terminal:
0009:fixme:exec:SHELL_execute flags ignored: 0x00000100 002b:err:winebrowser:wmain Failed to convert file URL to unix path
unsure if that's connected but the two machines involved are both Kali Linux
Any help is greatly appreciated!! thanks in advance
Related
I created a web server in Python 3.6 using http.server.HTTPServer, http.server.SimpleHTTPRequestHandler and socketserver.ThreadingMixIn. It works as expected and I can access the webpage from any device on the local network.
I compiled it with PyInstaller to create a Windows executable. The webpage works with localhost, but it is not accessible from any device on the local network.
I used nmap from another device to scan the computer hosting the web server, and it appears that the port used by the webserver (8080) is open when I run my script normally (with the Python interpreter), and everything works. However, when I use the executable produced by PyInstaller the port isn't open and the webpage not reachable.
The executable doesn't produce any errors, and apart from that everything works.
I have tried to run the .exe file as administrator, and to this disable my antivirus/firewall. It doesn't work.
Here is my PyInstaller command :
pyinstaller --runtime-tmpdir "" --onefile -i icon.ico script.py
And here is the relevant code in my python file :
import http.server
import socketserver
port = 8080
class ThreadingSimpleServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
pass #using this so the webserver can handle mutliple requests at a time
class myWebServer(http.server.SimpleHTTPRequestHandler):
def do_POST(self):
#does stuff
try:
server = ThreadingSimpleServer(('', port), myWebServer)
server.serve_forever()
except KeyboardInterrupt:
print('^C received, shutting down the program.')
server.socket.close()
I run your code and it works for me. The O.S. ask about opening the connection and everything seems to be ok. You must produce a log of some kind in order to let us understand what is going wrong. In my run i omit the -i switch because I don't have a .ico file.
Ok so I solved the issue but I still don't understand what caused it. Since the beginning I was building my script in a folder located in AppData : it wasn't working and I had no Windows firewall warning/confirmation showing up.
I moved my script to the Desktop and compiled it here : the Windows firewall confirmation showed up (this one) and the executable worked well.
I thought maybe the firewall might have flagged my program earlier and all the subsequent builds were blacklisted or something like that so I tried to compile the script in the original location, but this time I renamed it and I deleted all the files generated previously : it didn't work either (and no firewall confirmation/warning).
So now i'm pretty sure the error was caused by the firewall, and it had to do with the location from where the build was done, but I don't really understand why.
I built a Python application with Flask and run with Waitress server.
The app use local .csv files as the input data.
It can run well when running by command line. (ie. python webserver.py), I can load csv to read data, upload (to overwrite) the csv files.
But when I add it as a window's service (with nssm, or Window Resource Kit), my app can run, but the csv files only can be loaded by JS, not by the python.
It means, in service mode, if I load csv using js, It's ok, but when loading or uploading file (using python script) It returns "Internal Server Error".
My question is, how are running by command line and adding as Window's service different? How to make python script works with csv file when making it as service?
Any help is appreciated. Thank you so much.
This is the upload code.
#app.route('/uploadss', methods = ['GET', 'POST'])
def upload():
import os
print(request.files['file'])
if request.method=='POST':
file = request.files['file']
filenames = ['temperature.csv','inlet_clean_info.csv','log_data.csv','medium-term-temperature.csv']
if file.filename in filenames:
file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
return 'file uploaded successfully'
else:
return 'filename is not acceptable'
and I have add waitress webserver as service with:
> -(nssm) nssm.exe install MyService. Then add python path and the executed python file.
> -(Window ResKit) instsrv.exe LNG c:\reskit\srvany.exe. Then add "Parameter" key in Regedit, add "Application" String to point to <python path> <executed path>
In both cases, it returns "Internal Server Error"
This is the Error message, the returned response
" 500
Internal Server Error Internal Server Error The
server encountered an internal error and was unable to complete your
request. Either the server is overloaded or there is an error in the
application. "
The primary differences when running an app as a service are around environment.
Some things specifically:
Which user the service is running as.
When you start it from the command line, it's likely running as your user account. Your user account is likely to have different permissions from the Windows system account. This tends to cause issues with accessing files more than, for example, opening a port for an HTTP server. There may be other permissions related problems.
Environment variables, including PATH.
When you're in a command shell, windows has a PATH variable that tells it where to look for executable files. So if you type python it looks for python.exe in the current folder, then it searches through the PATH variable until it finds python.exe
You also have other environment variables that can be defined such as TMP (temporary folder), etc.
When it's running as a service, it's generally running in a different user context, which will have different environment variables, both the %TMP% and PATH. So one thing that could be happening is that it's trying to run python.exe but there's no python.exe on the path for the service user.
HKCU Registry entry
If your app uses the registry, and uses the HKEY_CURRENT_USER tree, this is likely different when it's running as a service. (HKEY_CURRENT_MACHINE is likely the same).
The folder that the application starts in
When you run it from the command line, you generally start it in the current folder. This means that it's possible to use relative paths (e.g. .\images) instead of absolute paths (c:\website\images).
If you were to change to a different folder, then the .\images version may not work.
When a program runs as a service, it usually seems to start in C:\Windows\System32
So you could investigate whether using absolute paths works. Or you could investigate whether there's a way to specify the startup folder.
Another thing to check (possibly first) - look for the log file
Normally web servers write a log file on the server somewhere.
The 500 error would go to the user, but there'd be a more detailed error written to a log. So find where that log file should be and check it out. (It's possible that it's not where it should be, and that could be to do with permissions associated with the User the service is running as). If it is there, it may help track down the particular issue.
I have been working on a flask application and it has been working just fine. however, for a couple of hours now, i have not been able to run my application on the web. After running the script on command line as usual, i would copy the ip address to my browser in order to display its content but will not respond anymore. I have tried changing port, and other troubleshooting i suppose should work but has still not been able to get it fixed. Any assistance is highly appreciated.
The error message is " this site can not be reached" when is actually running on the server in command line.
I've been following this guide:
https://developers.google.com/drive/v3/web/quickstart/python
and did everything up to the
python quickstart.py
part. When I do that it opens up a new browser (oddly not my default browser but whatever) and I get the OAuth screen, but once I click "Allow" it gives me a "localhost didn't send any data" error. The shell has:
/Library/Python/2.7/site-packages/oauth2client/_helpers.py:255:
UserWarning: Cannot access /Users/timothy.tran/.credentials/drive-
python-quickstart.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
0:297: execution error:
What does this mean and how can I fix it?
It means it cannot access this file:
Cannot access /Users/timothy.tran/.credentials/drive-
python-quickstart.json
because:
No such file or directory
I just got this quickstart running a while ago. When you click the oauth link generated by python commandline and it opens a random browser, copy that link and paste it in the browser where your gmail account (which you're also using in your google dev console) is currently logged-in. Let me know if you're still stuck after this.
Also I don't think you need a localhost to run this. If anything, I'd used a python virtual environment.
I am trying to use the pymodis (www.pymodis.org/index.html) python library to download modis data but I get stopped by my internet explorer proxy. I can deactivate it manually and it works fine but I would like to know if there is a way to modify the python script so that I don't have to do this everytime I need to download something.
The script for which I get an error is downmodis (https://github.com/lucadelu/pyModis/blob/master/pymodis/downmodis.py)
I get the following error:
raise Exception("There are some troubles with the server. "
Exception: There are some troubles with the server. The directory seems to be em
pty
This error comes from line 343
I also found this link (https://www.decalage.info/en/python/urllib2noproxy) which I feel might be usefull but I can't seem to get this solution to work (see line 253 from downmodis.py)