Fix CR + add 32/64bit binary choice

This commit is contained in:
Itay Mizeretz 2018-12-23 16:51:27 +02:00
parent 6ff2e7f541
commit 606f3525f7
2 changed files with 19 additions and 3 deletions

View File

@ -97,7 +97,8 @@ def get_msvcr():
def get_traceroute_binaries():
return [('traceroute', get_bin_file_path('traceroute'), 'BINARY')]
traceroute_name = 'traceroute32' if is_32_bit() else 'traceroute64'
return [(traceroute_name, get_bin_file_path(traceroute_name), 'BINARY')]
def get_monkey_filename():

View File

@ -10,6 +10,7 @@ import re
from six.moves import range
from infection_monkey.pyinstaller_utils import get_binary_file_path
from infection_monkey.utils import is_64bit_python
DEFAULT_TIMEOUT = 10
BANNER_READ = 1024
@ -191,6 +192,21 @@ def traceroute(target_ip, ttl):
return _traceroute_linux(target_ip, ttl)
def _get_traceroute_bin_path():
"""
Gets the path to the prebuilt traceroute executable
This is the traceroute utility from: http://traceroute.sourceforge.net
Its been built using the buildroot utility with the following settings:
* Statically link to musl and all other required libs
* Optimize for size
This is done because not all linux distros come with traceroute out-of-the-box, and to ensure it behaves as expected
:return: Path to traceroute executable
"""
return get_binary_file_path("traceroute64" if is_64bit_python() else "traceroute32")
def _parse_traceroute(output, regex, ttl):
"""
Parses the output of traceroute (from either Linux or Windows)
@ -244,8 +260,7 @@ def _traceroute_linux(target_ip, ttl):
Traceroute for a specific IP/name - Linux implementation
"""
traceroute_path = get_binary_file_path("traceroute")
cli = [traceroute_path,
cli = [_get_traceroute_bin_path(),
"-m", str(ttl),
target_ip]
proc_obj = subprocess.Popen(cli, stdout=subprocess.PIPE)