Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sedrubal
Masterarbeit
evaluation_tools
Commits
0bc2e7d6
Verified
Commit
0bc2e7d6
authored
Sep 25, 2021
by
Sebastian Endres
Browse files
Print input files table on run() not in __init__()
parent
520e22f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
plot_diagram.py
View file @
0bc2e7d6
...
...
@@ -131,35 +131,6 @@ class PlotCli:
self
.
traces
=
list
[
Trace
]()
cprint
(
f
"Plotting
{
len
(
trace_triples
)
}
traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
])
table
=
prettytable
.
PrettyTable
()
table
.
hrules
=
prettytable
.
FRAME
table
.
vrules
=
prettytable
.
ALL
table
.
field_names
=
[
colored
(
"left traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
colored
(
"right traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
colored
(
"keylog file"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
]
for
i
,
trace_triple
in
enumerate
(
trace_triples
):
table
.
add_row
(
[
colored
(
str
(
create_relpath
(
trace_triple
.
left_pcap_path
)),
attrs
=
[
"bold"
]
if
i
==
0
else
None
,
),
colored
(
str
(
create_relpath
(
trace_triple
.
right_pcap_path
)),
attrs
=
[
"bold"
]
if
i
==
0
else
None
,
),
create_relpath
(
trace_triple
.
keylog_path
)
if
trace_triple
.
keylog_path
else
colored
(
"-"
,
color
=
"grey"
),
]
)
print
(
table
)
for
trace_triple
in
trace_triples
:
left_trace
=
Trace
(
file
=
trace_triple
.
left_pcap_path
,
...
...
@@ -905,6 +876,37 @@ class PlotCli:
def
run
(
self
):
"""Run command line interface."""
cprint
(
f
"Plotting
{
len
(
self
.
traces
)
}
traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
])
table
=
prettytable
.
PrettyTable
()
table
.
hrules
=
prettytable
.
FRAME
table
.
vrules
=
prettytable
.
ALL
table
.
field_names
=
[
colored
(
"left traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
colored
(
"right traces"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
colored
(
"keylog file"
,
color
=
"cyan"
,
attrs
=
[
"bold"
]),
]
for
i
,
right_trace
in
enumerate
(
self
.
traces
):
assert
right_trace
.
pair_trace
table
.
add_row
(
[
colored
(
str
(
create_relpath
(
right_trace
.
pair_trace
.
input_file
)),
attrs
=
[
"bold"
]
if
i
==
0
else
None
,
),
colored
(
str
(
create_relpath
(
right_trace
.
input_file
)),
attrs
=
[
"bold"
]
if
i
==
0
else
None
,
),
create_relpath
(
right_trace
.
keylog_file
)
if
right_trace
.
keylog_file
else
colored
(
"-"
,
color
=
"grey"
),
]
)
print
(
table
)
mapping
=
{
PlotMode
.
OFFSET_NUMBER
:
{
"callback"
:
self
.
plot_offset_number
,
...
...
tracer.py
View file @
0bc2e7d6
...
...
@@ -131,8 +131,22 @@ class Trace:
"Trace"
]
=
None
# Trace for the other side (left / right)
@
property
def
input_file
(
self
)
->
Path
:
return
Path
(
self
.
_cap
.
input_filename
)
@
property
def
keylog_file
(
self
)
->
Optional
[
Path
]:
keylog_file
=
self
.
_cap
.
_override_prefs
.
get
(
"ssl.keylog_file"
)
if
keylog_file
:
return
Path
(
keylog_file
)
else
:
return
None
def
__str__
(
self
):
trace_file_name
=
Path
(
self
.
_cap
.
input_file
name
)
.
name
trace_file_name
=
self
.
input_file
.
name
if
self
.
_keylog_file
:
return
f
'<Trace
{
trace_file_name
}
"
{
self
.
_display_filter
}
" (
{
self
.
_keylog_file
}
)>'
...
...
@@ -154,7 +168,7 @@ class Trace:
else
:
# 2. use cmd tool to determine the cap length
output
=
subprocess
.
check_output
(
(
"capinfos"
,
"-r"
,
"-B"
,
"-T"
,
"-c"
,
self
.
_cap
.
input_file
name
),
(
"capinfos"
,
"-r"
,
"-B"
,
"-T"
,
"-c"
,
self
.
input_file
),
text
=
True
,
).
strip
()
...
...
@@ -194,7 +208,7 @@ class Trace:
return
self
.
_packets
input_file_rel_path
=
create_relpath
(
Path
(
self
.
_cap
.
input_file
name
)
)
input_file_rel_path
=
create_relpath
(
self
.
input_file
)
with
YaspinWrapper
(
debug
=
self
.
debug
,
text
=
f
"Loading
{
input_file_rel_path
}
"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment