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
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
c41c2867
Commit
c41c2867
authored
7 years ago
by
gpotter2
Browse files
Options
Downloads
Patches
Plain Diff
Small improvements
parent
1998f2f6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/automaton.py
+1
-1
1 addition, 1 deletion
scapy/automaton.py
scapy/pipetool.py
+48
-36
48 additions, 36 deletions
scapy/pipetool.py
with
49 additions
and
37 deletions
scapy/automaton.py
+
1
−
1
View file @
c41c2867
...
@@ -335,7 +335,7 @@ def select_objects(inputs, remain, customTypes=()):
...
@@ -335,7 +335,7 @@ def select_objects(inputs, remain, customTypes=()):
r
=
[]
r
=
[]
def
look_for_select
():
def
look_for_select
():
for
fd
in
inputs
:
for
fd
in
inputs
:
if
isinstance
(
fd
,
ObjectPipe
)
or
isinstance
(
fd
,
Automaton
.
_IO_fdwrapper
)
or
(
isinstance
(
fd
,
customTypes
)
)
:
if
isinstance
(
fd
,
(
ObjectPipe
,
Automaton
.
_IO_fdwrapper
)
+
customTypes
):
if
fd
.
checkRecv
():
if
fd
.
checkRecv
():
r
.
append
(
fd
)
r
.
append
(
fd
)
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
scapy/pipetool.py
+
48
−
36
View file @
c41c2867
...
@@ -62,6 +62,8 @@ class PipeEngine:
...
@@ -62,6 +62,8 @@ class PipeEngine:
raise
AttributeError
(
attr
)
raise
AttributeError
(
attr
)
def
checkRecv
(
self
):
def
checkRecv
(
self
):
"""
As select.select is not available, we check if there
is some data to read by using a list that stores pointers.
"""
return
len
(
self
.
__fd_queue
)
>
0
return
len
(
self
.
__fd_queue
)
>
0
def
fileno
(
self
):
def
fileno
(
self
):
...
@@ -493,46 +495,56 @@ class TermSink(Sink):
...
@@ -493,46 +495,56 @@ class TermSink(Sink):
self
.
opened
=
False
self
.
opened
=
False
if
self
.
openearly
:
if
self
.
openearly
:
self
.
start
()
self
.
start
()
def
_start_windows
(
self
):
def
start
(
self
):
if
not
self
.
opened
:
if
not
self
.
opened
:
self
.
opened
=
True
self
.
opened
=
True
if
WINDOWS
:
self
.
__f
=
get_temp_file
()
self
.
__f
=
get_temp_file
()
self
.
name
=
"
Scapy
"
if
self
.
name
is
None
else
self
.
name
self
.
name
=
"
Scapy
"
if
self
.
name
is
None
else
self
.
name
# Start a powershell in a new window and print the PID
# Start a powershell in a new window and print the PID
cmd
=
"
$app = Start-Process PowerShell -ArgumentList
'
-command &{$host.ui.RawUI.WindowTitle=
\\\"
%s
\\\"
;Get-Content
\\\"
%s
\\\"
-wait}
'
-passthru; echo $app.Id
"
%
(
self
.
name
,
self
.
__f
.
replace
(
"
\\
"
,
"
\\\\
"
))
cmd
=
"
$app = Start-Process PowerShell -ArgumentList
'
-command &{$host.ui.RawUI.WindowTitle=
\\\"
%s
\\\"
;Get-Content
\\\"
%s
\\\"
-wait}
'
-passthru; echo $app.Id
"
%
(
self
.
name
,
self
.
__f
.
replace
(
"
\\
"
,
"
\\\\
"
))
_p
=
subprocess
.
Popen
([
conf
.
prog
.
powershell
,
cmd
],
stdout
=
subprocess
.
PIPE
)
print
([
conf
.
prog
.
powershell
,
cmd
])
_output
,
_stderr
=
_p
.
communicate
()
_p
=
subprocess
.
Popen
([
conf
.
prog
.
powershell
,
cmd
],
stdout
=
subprocess
.
PIPE
)
# This is the process PID
_output
,
_stderr
=
_p
.
communicate
()
self
.
__p
=
int
(
_output
)
# This is the process PID
print
(
"
PID:
"
+
str
(
self
.
__p
))
self
.
__p
=
int
(
_output
)
def
_start_unix
(
self
):
print
(
"
PID:
"
+
str
(
self
.
__p
))
if
not
self
.
opened
:
else
:
self
.
opened
=
True
self
.
__r
,
self
.
__w
=
os
.
pipe
()
self
.
__r
,
self
.
__w
=
os
.
pipe
()
cmd
=
[
"
xterm
"
]
cmd
=
[
"
xterm
"
]
if
self
.
name
is
not
None
:
if
self
.
name
is
not
None
:
cmd
.
extend
([
"
-title
"
,
self
.
name
])
cmd
.
extend
([
"
-title
"
,
self
.
name
])
if
self
.
keepterm
:
if
self
.
keepterm
:
cmd
.
append
(
"
-hold
"
)
cmd
.
append
(
"
-hold
"
)
cmd
.
extend
([
"
-e
"
,
"
cat 0<&%i
"
%
self
.
__r
])
cmd
.
extend
([
"
-e
"
,
"
cat 0<&%i
"
%
self
.
__r
])
self
.
__p
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
executable
=
"
/bin/bash
"
)
self
.
__p
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
executable
=
"
/bin/bash
"
)
os
.
close
(
self
.
__r
)
os
.
close
(
self
.
__r
)
def
stop
(
self
):
def
start
(
self
):
if
WINDOWS
:
return
self
.
_start_windows
()
else
:
return
self
.
_start_unix
()
def
_stop_windows
(
self
):
if
not
self
.
keepterm
:
if
not
self
.
keepterm
:
self
.
opened
=
False
self
.
opened
=
False
if
not
WINDOWS
:
# Recipe to kill process with PID
os
.
close
(
self
.
__w
)
# http://code.activestate.com/recipes/347462-terminating-a-subprocess-on-windows/
self
.
__p
.
kill
()
import
ctypes
self
.
__p
.
wait
()
PROCESS_TERMINATE
=
1
else
:
handle
=
ctypes
.
windll
.
kernel32
.
OpenProcess
(
PROCESS_TERMINATE
,
False
,
self
.
__p
)
# Recipe to kill process with PID
ctypes
.
windll
.
kernel32
.
TerminateProcess
(
handle
,
-
1
)
# http://code.activestate.com/recipes/347462-terminating-a-subprocess-on-windows/
ctypes
.
windll
.
kernel32
.
CloseHandle
(
handle
)
import
ctypes
def
_stop_unix
(
self
):
PROCESS_TERMINATE
=
1
if
not
self
.
keepterm
:
handle
=
ctypes
.
windll
.
kernel32
.
OpenProcess
(
PROCESS_TERMINATE
,
False
,
self
.
__p
)
self
.
opened
=
False
ctypes
.
windll
.
kernel32
.
TerminateProcess
(
handle
,
-
1
)
os
.
close
(
self
.
__w
)
ctypes
.
windll
.
kernel32
.
CloseHandle
(
handle
)
self
.
__p
.
kill
()
self
.
__p
.
wait
()
def
stop
(
self
):
if
WINDOWS
:
return
self
.
_stop_windows
()
else
:
return
self
.
_stop_unix
()
def
_print
(
self
,
s
):
def
_print
(
self
,
s
):
if
self
.
newlines
:
if
self
.
newlines
:
s
+=
"
\n
"
s
+=
"
\n
"
...
...
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