p0dalirius / smbclient-ng

smbclient-ng, a fast and user friendly way to interact with SMB shares.
https://podalirius.net/
GNU General Public License v3.0
777 stars 64 forks source link

[bug] Emoji in filename breaks get command in smbclient-ng, (root cause in impacket) #94

Open 0xSegmented opened 3 months ago

0xSegmented commented 3 months ago

When using smbclientng, and there is a file that contains a emoji in it's filename, for example: 'Fixed issue 🎄 .msg', smbclientng results in being stuck. It is not possible to skip the file either, the entire smbclientng program hangs.

The 'get' command is ran on *.msg:

get *.msg
[..]
[error] [!] SMB Error: SMB SessionError: STATUS_OBJECT_NAME_NOT_FOUND(The object name is not found.)                                              
[1;92m⏺[0m[[1;94m\\10.0.0.1\test\docu\[0m]>                                                                                            
'19931232 Fixed issue 🎄 .msg' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0% • 0.0/123.1 kB • ? • -:--:--
[1;92m⏺[0m[[1;94m\\10.0.0.1\test\docu\[0m]>                                                                                            
'19931232 Fixed issue 🎄 .msg' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0% • 0.0/123.1 kB • ? • -:--:--
[1;92m⏺[0m[[1;94m\\10.0.0.1\test\docu\[0m]>

Pressing ctrl + c does not seem to kill it too.

0xSegmented commented 3 months ago

Checked if the impacket dependency is the problem. Seems like impacket filters the emoji titles out? Couldn't find it using smbclient from impacket.

p0dalirius commented 3 months ago

That is weird, I did not know that.

I will look into it

p0dalirius commented 3 months ago

Hi,

So I reproduced your environment and the problem comes from impacket:

image

It also crashes from the orginal smbclient.py:

image

So the handling of encoding seems to be broken in the get file of impacket..

Best regards