« Back to profile of OxYgEn

  • Python

    البحث عن أخطاء overflow في سكربتات C

    برنامج بسيط يقوم بالبحث عن أخطاء برمجية تسبب ثغرات الطفح overflow

    20:30 Jul 28 2010 | Tags :
    						#!/usr/bin/python
from os import system;system('clear')
print '''\t\t\t###################################
		\t###################################
		\t##### Pr0gramm1ng By : OxYgEn #####
		\t##### 1nf0 : buffer findEr    #####
		\t##### ver 1.1 ==> linuxac.org #####
		\t###################################
		\t###################################\n'''
from commands import getoutput
from sys import argv
function = ['gets','strcpy','strncpy','strcat','strncat','strtok','sprintf','snprintf','vsprintf','vsnprintf','vfprintf','strcmp','strncmp','strlen','strset','strstr','strpbrk','strlwr','strupr','strrev','strchr']
function_number = 0
number_line = 0
files = getoutput('ls').split('\n')
number_files = 0
Error = 0
if len(argv) > 1 :
	if argv[1] == '-d' :
		print '+'+'='*30+'start'+'='*30+'+\nline    file\t         \tline Error\n'+'-'*67
		while number_files < len(files) :
			if (files[number_files][-2:] == '.c') or (files[number_files][-4:] == '.txt') or (files[number_files][-4:] == '.cpp') :
				open_file = open(files[number_files],'r')
				data = open_file.read().split('\n')
				while function_number < len(function) :
					while number_line < len(data) :
						if function[function_number] in data[number_line] :
							Error+=1
							print "%d\t%s\t\t%s"%(number_line,files[number_files],data[number_line])
							number_line+=1
						else : number_line+=1
					number_line = 0
					function_number+=1
				function_number = 0
				number_files+=1
			else : number_files+=1
		print "finsh scan\nError %d\nnumber 0f all files : %d"%(Error,number_files)
	elif argv[1] == '-f':
		try : file = open(argv[2],'r')
		except IOError,e : print "Eror check the file ",str(e);exit(1) 
		data = file.read().split('\n')
		number_line = 0
		number_fun = 0
		while number_fun != len(function) :
			while number_line != len(data) :
				if function[number_fun] in data[number_line] :
					print '+'+'='*30+'start'+'='*30+'+\nline\t          \tline Error\n'+'-'*67
					print "%d\t\t%s"%(number_line,data[number_line])
					number_line+=1
					Error+=1
				else : number_line+=1
			number_line = 0
			number_fun+=1
		print '+'+'='*30+'End'+'='*30+'+\n'
		print "finsh scan %s number 0f Errors %d\n"%(argv[2],Error)
	else : print "u must Enter -d to scan dir\n-f to scan file\n"
else : print '''use 
1- to scan one file ==> $ python buffer_findEr.py -f vuln.c
2 - to scan dir    ===> $ python buffer_findeer.py -d'''
    			         
Add comment
To add a comment, please : Login or Sign up
    OxYgEn
    فيصل الزهراني
  • New visitor?

    On setCode, you can save your codes, functions and classes, you can also share them with your friends, and track your favorite developer

    Join the SetCode community
  • Your language here :