mandiant / flare-fakenet-ng

FakeNet-NG - Next Generation Dynamic Network Analysis Tool
Apache License 2.0
1.76k stars 356 forks source link

UnicodeEncodeError #128

Closed liartist closed 1 year ago

liartist commented 5 years ago

As I tried to execute fakenet.exe or fakenet.py, UnicodeEncodeError: 'ascii' codec can't encode characters in position 33-34: ordinal not in range(128) error came out. I think it's about unicode and ASCII encoding error. Since it's not about single source code, I couldn't use 'encoding:utf-8' method.

Here's my environment VirtualBox 6.0.8 Windows 7 32bit Python 2.7.16 I installed every requirements fakenet needs, so that would not be a problem.

htnhan commented 5 years ago

@liartist Thank you for using and supporting Fakenet-NG. Do you mind providing the complete stack trace to help us figure out where things fail?

Thanks,

liartist commented 5 years ago

Thank you for the fast support! I tried 2 versions of fakenet, the standalone (1.4.3) and python build (1.4.9) version. Here's 2 stack traces.

fakenet 1.4.3

C:\Users\Administrator\Desktop\fakenet1.4.3>fakenet.exe


| /\ | |/ / | \ | | __| | | \ | |/ __| | | / \ | ' /| | | | | | | |____| | | | | / /\ \ | < | | | . ` | | | |__| . ` | | |_ | | | / | . | || |\ | |__ | | | |\ | || | ||// __|__|| _|__| || || _|_____|

                    Version 1.4.3

               Developed by FLARE Team

06/06/19 01:54:47 PM [ FakeNet] Loaded configuration file: configs\def ault.ini 06/06/19 01:54:48 PM [ Diverter] Capturing traffic to packets20190606 135448.pcap 06/06/19 01:54:48 PM [ Diverter] Using default listener proxytcplistene r on port 38926 06/06/19 01:54:48 PM [ Diverter] Using default listener proxyudplistene r on port 38926 06/06/19 01:54:48 PM [ Diverter] WARNING: No gateways configured! Traceback (most recent call last): File "fakenet\fakenet.py", line 380, in File "fakenet\fakenet.py", line 355, in main File "fakenet\fakenet.py", line 156, in start File "fakenet\diverters\windows.py", line 97, in init File "fakenet\diverters\diverterbase.py", line 615, in init File "fakenet\diverters\winutil.py", line 381, in fix_gateway File "subprocess.py", line 185, in check_call File "subprocess.py", line 172, in call File "subprocess.py", line 394, in init File "subprocess.py", line 614, in _execute_child UnicodeEncodeError: 'ascii' codec can't encode characters in position 37-38: ord inal not in range(128) [2444] Failed to execute script fakenet

C:\Users\Administrator\Desktop\fakenet1.4.3>

fakenet 1.4.9

C:\Users\Administrator\Desktop\flare-fakenet-ng-master\fakenet>python fakenet.py


| /\ | |/ / | \ | | __| | | \ | |/ __| | | / \ | ' /| | | | | | | |____| | | | | / /\ \ | < | | | . ` | | | |__| . ` | | |_ | | | / | . | || |\ | |__ | | | |\ | || | ||// __|__|| _|__| || || _|_____|

                    Version 1.4.9

               Developed by FLARE Team

06/06/19 01:57:02 PM [ FakeNet] Loaded configuration file: configs\def ault.ini 06/06/19 01:57:03 PM [ Diverter] Capturing traffic to packets20190606 135703.pcap 06/06/19 01:57:03 PM [ Diverter] WARNING: No gateways configured! Traceback (most recent call last): File "fakenet.py", line 437, in main() File "fakenet.py", line 412, in main fakenet.start() File "fakenet.py", line 168, in start self.diverter = Diverter(self.diverter_config, self.listeners_config, ip_add rs, self.logging_level) File "C:\Users\Administrator\Desktop\flare-fakenet-ng-master\fakenet\diverters \windows.py", line 97, in init ip_addrs, logging_level) File "C:\Users\Administrator\Desktop\flare-fakenet-ng-master\fakenet\diverters \diverterbase.py", line 644, in init gw_ok = self.fix_gateway() File "C:\Users\Administrator\Desktop\flare-fakenet-ng-master\fakenet\diverters \winutil.py", line 381, in fix_gateway stderr=subprocess.PIPE) File "C:\Python27\lib\subprocess.py", line 185, in check_call retcode = call(*popenargs, *kwargs) File "C:\Python27\lib\subprocess.py", line 172, in call return Popen(popenargs, **kwargs).wait() File "C:\Python27\lib\subprocess.py", line 394, in init errread, errwrite) File "C:\Python27\lib\subprocess.py", line 614, in _execute_child args = '{} /c "{}"'.format (comspec, args) UnicodeEncodeError: 'ascii' codec can't encode characters in position 37-38: ord inal not in range(128)

C:\Users\Administrator\Desktop\flare-fakenet-ng-master\fakenet>

Thank you!

mah-nyan commented 4 years ago

This error is cause by Character code. In my case, my ethernet adapter is not English. I used Japanese name and same Error.But I changed "Ethernet0" taht was no error. fakenet

samrath-sudesh-acharya commented 1 year ago

@tinajn can you assign me this issue?

samrath-sudesh-acharya commented 1 year ago

@tinajn I don't think this problem exists anymore as every adapter name is of the type LPWSTR ( It is a pointer to a null-terminated string of 16-bit Unicode characters)

   IP_ADAPTER_ADDRESSES._fields_ = [
   ...
   ("FriendlyName",  LPWSTR),
   ...
  ]

Some Examples:

image image

[System Info]

OS Name:                   Microsoft Windows 10 Enterprise Evaluation
OS Version:                10.0.19045 N/A Build 19045
System Model:              VirtualBox
System Type:               x64-based PC
tinajn commented 1 year ago

@samrath-sudesh-acharya Thanks for testing this out! I have tested on my end and it appears to have been an issue with the way subprocess.check_call() handled non-ASCII characters in Python 2.

As @samrath-sudesh-acharya mentioned this issue is not observed anymore as we have ported to Python 3. @liartist could you test it out and close the issue?

tinajn commented 1 year ago

Closing this issue.