Drupal RCE
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
With PHP Filter Module
Katika toleo za zamani za Drupal (kabla ya toleo la 8), ilikuwa inawezekana kuingia kama admin na kuwezesha moduli ya PHP filter
, ambayo "Inaruhusu msimbo wa PHP uliowekwa ndani/kipande kutathminiwa." Lakini kuanzia toleo la 8 moduli hii haijaanzishwa kwa chaguo-msingi.
Unahitaji plugin ya php iwe imewekwa (angalia kwa kufikia /modules/php na ikiwa inarudisha 403 basi, ipo, ikiwa haipatikani, basi plugin ya php haijaanzishwa)
Nenda kwa Modules -> (Angalia) PHP Filter -> Hifadhi usanidi
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-33b0cd0a5bf70946deb6bc5c2dc0e6904642af9b%252Fimage%2520%28247%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=70537280&sv=1)
Kisha bonyeza Ongeza maudhui -> Chagua Ukurasa wa Msingi au Kifungu -> Andika php shellcode kwenye mwili -> Chagua PHP code katika Muundo wa maandiko -> Chagua Tazama
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-607d764091f974226ff1baac853144a317fc5838%252Fimage%2520%28338%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=aae34142&sv=1)
Hatimaye, fikia node mpya iliyoundwa:
Install PHP Filter Module
Katika toleo za sasa si tena inawezekana kufunga plugins kwa kuwa na ufikiaji wa wavuti tu baada ya usakinishaji wa default.
Kuanzia toleo 8 na kuendelea, PHP Filter moduli haifungwi kwa default. Ili kutumia kazi hii, itabidi tufunge moduli wenyewe.
Pakua toleo la hivi karibuni la moduli kutoka tovuti ya Drupal.
wget https://ftp.drupal.org/files/projects/php-8.x-1.1.tar.gz
Mara baada ya kupakua, nenda kwenye
Administration
>Reports
>Available updates
.Bonyeza
Browse
, chagua faili kutoka kwenye directory tuliyopakia, kisha bonyezaInstall
.Mara moduli ikishafungwa, tunaweza kubonyeza
Content
na kuunda ukurasa mpya wa msingi, kama tulivyofanya katika mfano wa Drupal 7. Tena, hakikisha uchaguePHP code
kutoka kwenyeText format
dropdown.
Backdoored Module
Katika toleo za sasa si tena inawezekana kufunga plugins kwa kuwa na ufikiaji wa wavuti tu baada ya usakinishaji wa default.
Moduli yenye backdoor inaweza kuundwa kwa kuongeza shell kwenye moduli iliyopo. Moduli zinaweza kupatikana kwenye tovuti ya drupal.org. Hebu chague moduli kama CAPTCHA. Shuka chini na nakili kiungo cha tar.gz archive.
Pakua archive na uondoe yaliyomo yake.
Tengeneza PHP web shell yenye maudhui:
Next, we need to create a
.htaccess
file to give ourselves access to the folder. This is necessary as Drupal denies direct access to the/modules
folder.
Mipangilio iliyo juu itatumika kwa sheria za / folda tunapohitaji faili katika /modules. Nakili faili hizi mbili kwenye folda ya captcha na uunde archive.
Ikiwa tuna ufikiaji wa kiutawala kwenye tovuti, bonyeza
Manage
kishaExtend
kwenye upande wa menyu. Kisha, bonyeza kitufe cha+ Install new module
, na tutapelekwa kwenye ukurasa wa usakinishaji, kamahttp://drupal-site.local/admin/modules/install
Tembelea archive ya Captcha iliyokuwa na backdoor na bonyezaInstall
.Mara baada ya usakinishaji kufanikiwa, tembelea
/modules/captcha/shell.php
ili kutekeleza amri.
Backdooring Drupal kwa kutumia Usawazishaji wa Mipangilio
Post iliyoshirikiwa na Coiffeur0x90
Sehemu ya 1 (kuanzisha Media na Media Library)
Katika menyu ya Extend (/admin/modules), unaweza kuanzisha kile kinachoweza kuonekana kama plugins ambazo tayari zimesakinishwa. Kwa kawaida, plugins Media na Media Library hazionekani kuanzishwa, hivyo hebu tuzianzishe.
Kabla ya kuanzisha:
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-4c7c93f136e5cef5e20e7ede64b22028ca72648a%252Fimage%2520%284%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=97527791&sv=1)
Baada ya kuanzisha:
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-1ec78aebd66cd90a926937e9afef92bee1bbd873%252Fimage%2520%281%29%2520%281%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d0b0d9b2&sv=1)
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-176e28e260ced93a729f3ca6f493c54de2ca3325%252Fimage%2520%282%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=b98c91c3&sv=1)
Sehemu ya 2 (kutumia kipengele Usawazishaji wa Mipangilio)
Tutatumia kipengele Usawazishaji wa Mipangilio kutupa (kuhamasisha) na kupakia (kuagiza) entries za mipangilio ya Drupal:
/admin/config/development/configuration/single/export
/admin/config/development/configuration/single/import
Patch system.file.yml
Hebu tuanze kwa kupatch entry ya kwanza allow_insecure_uploads
kutoka:
File: system.file.yml
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-17acb7d7e32d50321420fc6980081693ff3c2488%252Fimage%2520%283%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7606b706&sv=1)
Kwa:
File: system.file.yml
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-92ceed74582786045e9b3021748efcdf10eaab62%252Fimage%2520%284%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=1b03d5f0&sv=1)
Patch field.field.media.document.field_media_document.yml
Kisha, pata kipengele cha pili file_extensions
kutoka:
File: field.field.media.document.field_media_document.yml
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-e7f03abf85835acd9c32e403c7957baddf76124c%252Fimage%2520%285%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=dbb622a6&sv=1)
Ili:
Faili: field.field.media.document.field_media_document.yml
Sijatumia katika blogu hii lakini inabainishwa kuwa inawezekana kufafanua kiingilio
file_directory
kwa njia yoyote na kwamba ina udhaifu wa shambulio la path traversal (hivyo tunaweza kurudi juu ndani ya mti wa mfumo wa faili wa Drupal).
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-e5ab74cb813cf4b74bf72e0029bab9303fa0ba0d%252Fimage%2520%286%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=16d33424&sv=1)
Sehemu ya 3 (kutumia kipengele Ongeza Hati)
Hatua ya mwisho ni rahisi zaidi, na imegawanywa katika hatua ndogo mbili. Ya kwanza ni kupakia faili katika muundo wa .htaccess ili kutumia maagizo ya Apache na kuruhusu faili za .txt kutafsiriwa na injini ya PHP. Ya pili ni kupakia faili ya .txt inayoshikilia mzigo wetu.
Faili: .htaccess
Kwa nini hila hii ni nzuri?
Kwa sababu mara tu Webshell (ambayo tutaita LICENSE.txt) inapowekwa kwenye seva ya Mtandao, tunaweza kuhamasisha amri zetu kupitia $_COOKIE
na katika kumbukumbu za seva ya Mtandao, hii itaonekana kama ombi halali la GET kwa faili la maandiko.
Kwa nini kuita Webshell yetu LICENSE.txt?
Kwa sababu tu ikiwa tutachukua faili ifuatayo, kwa mfano core/LICENSE.txt (ambayo tayari ipo katika msingi wa Drupal), tuna faili ya mistari 339 na ukubwa wa 17.6 KB, ambayo ni bora kwa kuongeza kipande kidogo cha msimbo wa PHP katikati (kwa sababu faili ni kubwa vya kutosha).
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-511d745288778e33bd8a1eaa02cb3ec9a9484b6b%252Fimage%2520%287%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=11583abd&sv=1)
Faili: LICENSE.txt iliyorekebishwa
Sehemu ya 3.1 (pakia faili .htaccess)
Kwanza, tunatumia kipengele Add Document (/media/add/document) kupakia faili yetu inayokuwa na maagizo ya Apache (.htaccess).
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-4464dc17125af4ce4ff46ef4c85ba124775fd892%252Fimage%2520%288%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=73432ac9&sv=1)
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-a3d5f99f09936ab255513583290236e3edf2fb64%252Fimage%2520%289%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=40097094&sv=1)
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-210d7bd3fb7f095bb7e92b210d91e63f12968897%252Fimage%2520%2810%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=f0615055&sv=1)
Sehemu ya 3.2 (pakia faili LICENSE.txt)
Kisha, tunatumia tena kipengele Add Document (/media/add/document) kupakia Webshell iliyofichwa ndani ya faili la leseni.
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-277c44d2cad5775066e0429dbda5f22b6f66f554%252Fimage%2520%2811%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=17583627&sv=1)
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-fd5fec3d9950b64fd4989eaf686df6f7966029b3%252Fimage%2520%2812%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=5b339d10&sv=1)
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-4c2c4ab67b3633aad28099287e4c1d48dc337689%252Fimage%2520%2813%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=9dc09fa6&sv=1)
Sehemu ya 4 (mawasiliano na Webshell)
Sehemu ya mwisho inahusisha mawasiliano na Webshell.
Kama inavyoonyeshwa katika picha ifuatayo, ikiwa cookie inayotarajiwa na Webshell yetu haijafafanuliwa, tunapata matokeo yafuatayo tunaposhughulikia faili kupitia kivinjari cha wavuti.
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-f5207ab5b112e3b9da915193f7f2e73db318399e%252Fimage%2520%2814%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7a599b73&sv=1)
Wakati mshambuliaji anapoweka cookie, anaweza kuwasiliana na Webshell na kutekeleza amri zozote anazotaka.
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-11fd861cfefe62fd4421623f34499ce77ad1e142%252Fimage%2520%2815%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=86674bbd&sv=1)
Na kama unavyoona katika kumbukumbu, inaonekana kama faili ya txt pekee ndiyo imeombwa.
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F3018635170-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FCtGnfY5n0YCGcWtBkgwe%252Fuploads%252Fgit-blob-5d7f744a6dab44d590135b108e5eb9e3e2f118e9%252Fimage%2520%2816%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ac9ddd93&sv=1)
Asante kwa kuchukua muda kusoma makala hii, natumai itakusaidia kupata baadhi ya shells.
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Last updated