Im trying to write little http proxy server just for testing how scapy handles packet with StreamSocket.
from scapy.all import *
import socket
sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print "Start"
sk.bind(("127.0.0.1",8090))
sk.listen(1)
conn , addr = sk.accept()
ss = StreamSocket(conn)
r = ss.recv(2048)
print r
ss.close()
When I got the line r = ss.recv(2048) it says (on scapy 2.2.0):
Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
pad = pkt.getlayer(Padding)
NameError: global name 'Padding' is not defined
I have tried to update my scapy (from 2.2.0 to 2.3.2) and it does the same error:
Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
pkt = self.basecls(pkt)
NameError: global name 'Padding' is not defined
Please Help?
sorry for my bad english
Note: I have windows 7 64 bit , python 2.6 and now scapy 2.3.2
I found that after uninstalling and reinstalling scapy I didnt reboot my machine and that made the error!
For people that might get my error about, just remove scapy from your machine and reboot it and install latest scapy version.
Related
I am trying to run pox controller using the command
python2 ./pox.py forwarding. l3_detectionEntropyemphasized text
Then I got this error.
` Traceback (most recent call last):
File "./pox.py", line 43, in <module>
from pox.boot import boot
File "/home/name/pox/pox/boot.py", line 38, in <module>
import pox.core
File "/home/name/pox/pox/core.py", line 182, in <module>
import pox.lib.recoco as recoco
File "/home/name/pox/pox/lib/recoco/__init__.py", line 1, in <module>
from .recoco import *
File "/home/name/pox/pox/lib/recoco/recoco.py", line 17, in <module>
from queue import PriorityQueue
ImportError: No module named queue`
Also I have tried to run it in python3 by converting it into python3 Then i got this error.
`Traceback (most recent call last):
File "/home/shivani/pox/pox/boot.py", line 74, in do_import2
__import__(name, level=0)
File "/home/shivani/pox/pox/forwarding/l3_detectionEntropy.py", line 129
print "dpid port and its packet count: ", str(event.connection.dpid),
str(diction[event.connection.dpid]), str(diction[event.connection.dpid][event.port])
^
SyntaxError: invalid syntax
Could not import module: forwarding.l3_detectionEntropy`
How to solve these error??
Adding paranthesis around the print statement should fix the issue.
Python 3 would raise a SyntaxError if we called the print function the Python 2-way without the parentheses.
I am trying to connect Pepper to Dialogflow. The Dialogflow SDK is stored in the project folder/lib. The python version used by Pepper is 2.7. I use python 2.7.9.
self.folderName = os.path.join(self.framemanager.getBehaviorPath(self.behaviorId), "..\lib")
if self.folderName not in sys.path:
sys.path.append(self.folderName)
self.log(self.folderName)
import apiai
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
When running the code, I got the errors:
[ERROR] behavior.box :_safeCallOfUserMethod:281 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1338328200__root__test_1: Traceback (most recent call last):
File "C:\PROGRA~2\ALDEBA~1\CHOREG~1.1\lib\naoqi.py", line 271, in _safeCallOfUserMethod
func()
File "<string>", line 23, in onInput_onStart
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\__init__.py", line 9, in <module>
from .requests.query import Entry
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\__init__.py", line 3, in <module>
from .request import Request
File "C:\Users\loadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\request.py", line 9, in <module>
from httplib import HTTPSConnection
ImportError: cannot import name HTTPSConnection
Any ideas how to solve it?
This program must be run on the robot, rather than on your computer.
I have this python code which getting data from socket's and printing to console. But in working process I getting this error code
Traceback (most recent call last):
File "server.py", line 1, in <module>
import ssl, socket
File "/home/ssl.py", line 20, in <module>
returned from time.time())
AttributeError: 'module' object has no attribute 'wrap_socket'
maybe somebody has any idea how I can fix this issue?
import ssl, socket
sock = ssl.wrap_socket(socket.socket(), 'server.key', 'server.crt', True)
sock.bind( ('', 443) )
sock.listen(10)
while True:
conn, addr = sock.accept()
data = conn.recv(4)
print data
thank you
You most likely have a file named ssl.py in the same directory, as indicated by this part of the error:
File "/home/ssl.py", line 20, in
returned from time.time())
and the script is trying to import that instead of the system level module. If you cannot change the name of that file, try using absolute and relative imports.
I'm trying a simple code, just sending an ARP packet:
from scapy.all import *
p = ARP()
send(p)
and I get this error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
send(p)
File "C:\Python26\scapy\sendrecv.py", line 251, in send
__gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop,
count=count,verbose=verbose, realtime=realtime)
File "C:\Python26\scapy\sendrecv.py", line 234, in __gen_send
s.send(p)
File "C:\Python26\scapy\arch\pcapdnet.py", line 237, in send
ifs = dnet.eth(iff)
File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: No error
My OS is windows 8 64bit. I tried in win7 64bit and got the same problem. I tried in win7 32bit and that works fine.
I can't understand why.. please help..
I guess you have to inform the interface ID, like this:
sendp(netpacket, iface='eth1')
I had the same trouble as yours, did like I said and got it!
I just installed libgmail on CentOS 5, python 2.6 with easy_install. There was a problem, until i installed mechanize manually. After that easy_install said OK and i wrote 1st test program from the sample i googled:
import libgmail
ga = libgmail.GmailAccount("someaccount#gmail.com", "mypassword")
ga.login()
folder = ga.getMessagesByFolder('inbox')
for thread in folder:
print thread.id, len(thread), thread.subject
for msg in thread:
print " ", msg.id, msg.number, msg.subject
print msg.source
I get the following error message:
Traceback (most recent call last):
File "gm.py", line 4, in <module>
ga.login()
File "build/bdist.linux-i686/egg/libgmail.py", line 305, in login
File "build/bdist.linux-i686/egg/libgmail.py", line 340, in _retrievePage
File "build/bdist.linux-i686/egg/mechanize/_request.py", line 31, in __init__
File "build/bdist.linux-i686/egg/mechanize/_rfc3986.py", line 62, in is_clean_uri
TypeError: expected string or buffer
It seems, i get a problem not with my python code, but with libgmail installation. Any clues, anyone?
libgmail is deprecated and has stopped developing, since gmail started offering imap access.
Use imaplib or similar (twisted.mail comes to mind, example code here).