Skip to content

Instantly share code, notes, and snippets.

@mfowl
Created March 8, 2019 22:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfowl/6d2de19633e91bff2f1a6f6899892d24 to your computer and use it in GitHub Desktop.
Save mfowl/6d2de19633e91bff2f1a6f6899892d24 to your computer and use it in GitHub Desktop.
# This script locates potentially dangerous functions that could introduce a vulnerability if they are used incorrectly.
#@author: VDA Labs (Michael Fowl)
#@category Functions
print "Searching for banned functions..."
# Microsoft SDL banned.h list.
blist = (["strcpy", "strcpyA", "strcpyW", "wcscpy", "_tcscpy", "_mbscpy", "StrCpy",
"StrCpyA", "StrCpyW", "lstrcpy", "lstrcpyA", "lstrcpyW", "_tccpy", "_mbccpy",
"_ftcscpy", "strcat", "strcatA", "strcatW", "wcscat", "_tcscat", "_mbscat",
"StrCat", "StrCatA", "StrCatW", "lstrcat", "lstrcatA", "lstrcatW", "StrCatBuff",
"StrCatBuffA", "StrCatBuffW", "StrCatChainW", "_tccat", "_mbccat", "_ftcscat",
"sprintfW", "sprintfA", "wsprintf", "wsprintfW", "wsprintfA", "sprintf", "swprintf",
"_stprintf", "wvsprintf", "wvsprintfA", "wvsprintfW", "vsprintf", "_vstprintf",
"vswprintf", "strncpy", "wcsncpy", "_tcsncpy", "_mbsncpy", "_mbsnbcpy", "StrCpyN",
"StrCpyNA", "StrCpyNW", "StrNCpy", "strcpynA", "StrNCpyA", "StrNCpyW", "lstrcpyn",
"lstrcpynA", "lstrcpynW", "strncat", "wcsncat", "_tcsncat", "_mbsncat", "_mbsnbcat",
"StrCatN", "StrCatNA", "StrCatNW", "StrNCat", "StrNCatA", "StrNCatW", "lstrncat",
"lstrcatnA", "lstrcatnW", "lstrcatn", "gets", "_getts", "_gettws", "IsBadWritePtr",
"IsBadHugeWritePtr", "IsBadReadPtr", "IsBadHugeReadPtr", "IsBadCodePtr", "IsBadStringPtr"])
# loop through program functions
function = getFirstFunction()
while function is not None:
for banned in blist:
if function.getName() == banned:
print "%s found at %s" % (function.getName(),function.getEntryPoint())
#function.setComment("Badness!")
function = getFunctionAfter(function)
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment