Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
edd94bc7
Commit
edd94bc7
authored
8 years ago
by
gpotter2
Committed by
Guillaume Valadon
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Windows] Whois support (#474)
* Fix whois on Windows * Better whois server and parsing * Small fixes
parent
97af8165
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
scapy/base_classes.py
+2
-1
2 additions, 1 deletion
scapy/base_classes.py
scapy/layers/inet.py
+7
-1
7 additions, 1 deletion
scapy/layers/inet.py
scapy/utils.py
+35
-4
35 additions, 4 deletions
scapy/utils.py
with
44 additions
and
6 deletions
scapy/base_classes.py
+
2
−
1
View file @
edd94bc7
...
...
@@ -77,7 +77,8 @@ class Net(Gen):
self
.
repr
=
net
self
.
parsed
,
self
.
netmask
=
self
.
_parse_net
(
net
)
def
__str__
(
self
):
return
self
.
repr
def
__iter__
(
self
):
for
d
in
xrange
(
*
self
.
parsed
[
3
]):
...
...
This diff is collapsed.
Click to expand it.
scapy/layers/inet.py
+
7
−
1
View file @
edd94bc7
...
...
@@ -16,6 +16,7 @@ from scapy.base_classes import Gen
from
scapy.data
import
*
from
scapy.layers.l2
import
*
from
scapy.config
import
conf
from
scapy.consts
import
WINDOWS
from
scapy.fields
import
*
from
scapy.packet
import
*
from
scapy.volatile
import
*
...
...
@@ -23,6 +24,7 @@ from scapy.sendrecv import sr,sr1,srp1
from
scapy.plist
import
PacketList
,
SndRcvList
from
scapy.automaton
import
Automaton
,
ATMT
from
scapy.error
import
warning
from
scapy.utils
import
whois
import
scapy.as_resolvers
...
...
@@ -36,6 +38,10 @@ class IPTools(object):
"""
Add more powers to a class with an
"
src
"
attribute.
"""
__slots__
=
[]
def
whois
(
self
):
"""
whois the source and print the output
"""
if
WINDOWS
:
print
whois
(
self
.
src
)
else
:
os
.
system
(
"
whois %s
"
%
self
.
src
)
def
ottl
(
self
):
t
=
[
32
,
64
,
128
,
255
]
+
[
self
.
ttl
]
...
...
This diff is collapsed.
Click to expand it.
scapy/utils.py
+
35
−
4
View file @
edd94bc7
...
...
@@ -1275,3 +1275,34 @@ def make_lined_table(*args, **kargs):
def
make_tex_table
(
*
args
,
**
kargs
):
__make_table
(
lambda
l
:
"
%s
"
,
lambda
l
:
"
& %s
"
,
"
\\\\
"
,
seplinefunc
=
lambda
a
,
x
:
"
\\
hline
"
,
*
args
,
**
kargs
)
###############################################
### WHOIS CLIENT (not available on windows) ###
###############################################
def
whois
(
ip_address
):
"""
Whois client for Python
"""
whois_ip
=
str
(
ip_address
)
try
:
query
=
socket
.
gethostbyname
(
whois_ip
)
except
:
query
=
whois_ip
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
((
"
whois.ripe.net
"
,
43
))
s
.
send
(
query
+
"
\r\n
"
)
answer
=
''
while
True
:
d
=
s
.
recv
(
4096
)
answer
+=
d
if
not
d
:
break
s
.
close
()
ignore_tag
=
"
remarks:
"
# ignore all lines starting with the ignore_tag
lines
=
[
line
for
line
in
answer
.
split
(
"
\n
"
)
if
not
line
or
(
line
and
not
line
.
startswith
(
ignore_tag
))]
# remove empty lines at the bottom
for
i
in
range
(
1
,
len
(
lines
)):
if
not
lines
[
-
i
].
strip
():
del
lines
[
-
i
]
else
:
break
return
"
\n
"
.
join
(
lines
[
3
:])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment