mvrozanti / RAT-via-Telegram

Windows Remote Administration Tool via Telegram
MIT License
646 stars 347 forks source link

Keylogs problem #51

Open Dagdelo opened 5 years ago

Dagdelo commented 5 years ago

After starting the server this log is spill:

File "C:\Python37\lib\ctypes__init__.py", line 63, in create_string_buffer raise TypeError(init)

The lines of codes that the log complains about it:

118> executable = ctypes.create_string_buffer("\x00" * 512)
...
134> data = get_curr_window()
...
mvrozanti commented 5 years ago

We recently moved to python 3.7 there might be a few bugs here and there. I'm already looking into it

mvrozanti commented 5 years ago

Please try 13a7b8d9cb13c513765413fef9eff152cd8495bf (lines 119 and 122)

mvrozanti commented 5 years ago

Didn't mean to close this. @Dagdelo Please try pip install pyHook-1.5.1-cp37-cp37m-win_amd64.whl and recompiling; we added a new pyHook wheel for Python3.7

Dagdelo commented 5 years ago

Well seems to be fix, but still don't work properly.

                Got message from 400496256: /keylogs

TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'

The keylogs output file:

[ PID 10500 - b'Telegram.exe' - b'Telegram' ]

PCKEKEYLOGS [ PID 10500 - b'Telegram.exe' - b'Telegram' ] KEKEY

Seem's to only keylogged the Telegram window. I type over Chrome and Whatsapp. And of course, after the complain the servers stops.

mvrozanti commented 5 years ago

Are you sure you have recompiled? I'm getting ok results on Chrome browser:

[ PID 1728 - b'chrome.exe' - b'test - Pesquisa Google - Google Chrome' ]
EH<Back><Back><Back><Back><Back><Back>ESTE<Space>EH<Space>UM<Space>TESTE<Space>AMIGO<Return>
[ PID 2952 - b'cmd.exe' - b'C:\\Windows\\system32\\cmd.exe - RATAttack.exe' ]
<Lcontrol><Lmenu><Tab>
[ PID 1176 - b'Explorer.EXE' - b'Documents' ]
<Lmenu><Tab>
Dagdelo commented 5 years ago

Yeah, I'm Recompile and the RATAttack.exe works well, buts is for another issue... But unfortunutelly only logs on telegram window... And after while this logs output in the server:

TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'

mvrozanti commented 5 years ago

We actually changed the pyHook wheel to match Python 3.7; can you try running pip install pyHook-1.5.1-cp37-cp37m-win_amd64.whl and recompiling?

Dagdelo commented 5 years ago

With original pyHook, on Python 3.7/Windows 10:

C:\RAT-via-Telegram>python RATAttack.py {'message_id': 223, 'from': {'id': xxxxxxxxx, 'is_bot': True, 'first_name': 'RAT Bot', 'username': 'D83_bot'}, 'chat': {'id': yyyyyyyyy, 'first_name': 'Henrique', 'type': 'private'}, 'date': 1540240212, 'text': "Dagdelo: I'm up."} Dagdelo: I'm up. Listening for commands on Dagdelo... \\\DBLOCO\ TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'

With pyHook fixed version from Answeror (found on this reddit post):

C:\RAT-via-Telegram>python RATAttack.py {'message_id': 224, 'from': {'id': 663000828, 'is_bot': True, 'first_name': 'RAT Bot', 'username': 'D83_bot'}, 'chat': {'id': 400496256, 'first_name': 'Henrique', 'type': 'private'}, 'date': 1540240784, 'text': "Dagdelo: I'm up."} Dagdelo: I'm up. Listening for commands on Dagdelo... C:\RAT-via-Telegram>

With this the program simples stops to working after opening notepad (Bloco de notas) or typing some combinations like 'Alt+Tab'; 'Win+D'; 'Win+M' ... etc.

mvrozanti commented 5 years ago

Can you post the output of python -V?

Dagdelo commented 5 years ago

Here the output (much longer then I was expected!) If you want python -V:

C:\Users\Henrique>python -V Python 3.7.0

mvrozanti commented 5 years ago

The problem

Probable fix

Another problem:

Known bugs PyInstaller can't build single-file executables using pyHook. This may be fixed in 1.5.1, but hasn't been tested.

We could try and replace current pyHook module but it seems a lot of work; I'm yet to read this fork

Dagdelo commented 5 years ago

Cool. But u looked at https://github.com/Answeror/pyhook_py3k ?

mvrozanti commented 5 years ago

Seems legit but I still gotta take the time to read it; if it works we can add it as a submodule

mvrozanti commented 5 years ago

Can others confirm this issue in their machines?

Dagdelo commented 5 years ago

Sobre o programa não conseguir registrar o chrome: isso só acontece quando o chrome está sendo executado com privilégios administrativos (como administrador) e o programa está sendo executado sem esses privilégios.

Sobre o programa encerrar quando encontrar certos caracteres no título de janelas: isso é um bug do pyhook com relação a encode.

--

About the program can not register chrome: this only happens when chrome is running with administrative privileges (as administrator) and the program is running without these privileges.

On the program quit when encountering certain characters in the title of windows: this is a pyhook bug with respect to encode.

mvrozanti commented 5 years ago

It should be the other way around: the RAT being run as admin and Chrome (usually) being opened with regular priviledges. Did you get it working though? Is this a closeable issue?

Dagdelo commented 5 years ago

Yeah. But for run with admin in the target machine, it needs to bypass UAC or find another way to escalate privileges to admin.

mvrozanti commented 5 years ago

I'm not sure if the latest windows versions are still vulnerable but... can anyone test this?

Dagdelo commented 5 years ago

I think it's pretty complicated. There are several exploits in various languages but in python I do not know any ... And you still need to obfuscate the code so that the anti-virus does not detect it.

Ali-Fani commented 5 years ago

I'm not sure if the latest windows versions are still vulnerable but... can anyone test this?

it works but its python 2.7 needs to be ported

dudeisbrendan03 commented 5 years ago

pwnage

dudeisbrendan03 commented 5 years ago

Examples of UAC bypasses in python

Dagdelo commented 5 years ago

pwnage

Note found.

Ali-Fani commented 5 years ago

Can others confirm this issue in their machines?

it happends here too

dudeisbrendan03 commented 5 years ago

My bad this is pwnage

dudeisbrendan03 commented 5 years ago

Put the wrong link @Dagdelo that one works ^

mvrozanti commented 5 years ago

Huge dependency but seems so useful. Great find. I wonder if it's worth the bloat.

dudeisbrendan03 commented 5 years ago

It's on 2.7, instead of using it as a dependency go ahead and look for one UAC exploit that currently works - mold that into something we can use and then credit the original user. No point in bringing in everything

dudeisbrendan03 commented 5 years ago

It would be a lot of work to bring it all anyway, would have to make it all functional on PY3