VirusTotal API 2.0 UDF


SUBMITTED BY: Guest

DATE: May 28, 2013, 9:54 a.m.

FORMAT: Text only

SIZE: 6.6 kB

HITS: 1940

  1. #include-once
  2. #include "WinHttp.au3"
  3. ; #INDEX# =================================================================================================
  4. ; Title .........: VT.au3
  5. ; AutoIt Version : 3.3.8.1
  6. ; Language ......: English
  7. ; Description ...: VirusTotal public API version 2.0 implementation in Autoit
  8. ;thanks to: trancexx|ProgAndy "WinHttp.au3" & www.virustotal.com
  9. ;Reference https://www.virustotal.com/es/documentation/public-api
  10. ;Written by Danyfirex
  11. ;Date 12/05/2013
  12. ; #FUNCTION# =============================================================================================
  13. ;===================CONSTANTS/CONSTANTES=======================
  14. Global Const $VTPage="www.virustotal.com"
  15. ;==============================================================
  16. ; #FUNCTIONS/FUNCIONES# =======================================
  17. ;VT_Open
  18. ;VT_Close
  19. ;VT_File_Report
  20. ;VT_Url_Report
  21. ;VT_Url_Scan
  22. ;VT_File_Scan
  23. ;VT_File_Rescan
  24. ;VT_Put_Comment
  25. ; ==============================================================
  26. ; #FUNCTION# =============================================================================================
  27. ; Name...........: VT_Open
  28. ; Description ...: Initialize and get session handle & connection handle
  29. ; Syntax.........: VT_Open()
  30. ; #FUNCTION# =============================================================================================
  31. Func VT_Open()
  32. Global $hOpen = _WinHttpOpen()
  33. Global $hConnect = _WinHttpConnect($hOpen, $VTPage)
  34. EndFunc ;==> VT_Open
  35. ; #FUNCTION# =============================================================================================
  36. ; Name...........: VT_Open
  37. ; Description ...: Close handles
  38. ; Syntax.........: VT_Open()
  39. ; #FUNCTION# =============================================================================================
  40. Func VT_Close()
  41. _WinHttpCloseHandle($hConnect)
  42. _WinHttpCloseHandle($hOpen)
  43. EndFunc
  44. ; #FUNCTION# =============================================================================================
  45. ; Name...........: VT_File_Report
  46. ; Description ...: retrieve a scan report on a given file
  47. ; Syntax.........: VT_File_Report($Resource,$APIkey)
  48. ; Parameters ....: $Resource - A md5/sha1/sha256/scan_id hash will retrieve the most recent report.
  49. ; $APIkey - your API key.
  50. ; #FUNCTION# =============================================================================================
  51. Func VT_File_Report($Resource,$APIkey)
  52. Return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/file/report", Default,"resource="& $Resource & "&key=" & $APIkey)
  53. EndFunc
  54. ; #FUNCTION# =============================================================================================
  55. ; Name...........: VT_Url_Report
  56. ; Description ...: retrieve a scan report on a given URL
  57. ; Syntax.........: VT_Url_Report($URL,$APIkey)
  58. ; Parameters ....: $URL - a URL.
  59. ; $APIkey - your API key.
  60. ; #FUNCTION# =============================================================================================
  61. Func VT_Url_Report($URL,$APIkey)
  62. Return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/url/report", Default, "resource=" & $URL & "&key=" & $APIkey)
  63. EndFunc
  64. ; #FUNCTION# =============================================================================================
  65. ; Name...........: VT_Url_Scan
  66. ; Description ...: submit a URL for Scanning
  67. ; Syntax.........: VT_Url_Scan($URL,$APIkey)
  68. ; Parameters ....: $URL - The URL that should be scanned.
  69. ; $APIkey - your API key.
  70. ; #FUNCTION# =============================================================================================
  71. Func VT_Url_Scan($URL,$APIkey)
  72. Return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/url/scan", Default, "url="& $URL & "&key="&$APIkey)
  73. EndFunc
  74. ; #FUNCTION# =============================================================================================
  75. ; Name...........: VT_Url_Scan
  76. ; Description ...: submit a file for Scanning
  77. ; Syntax.........: VT_File_Scan($File,$APIkey,$sBoundary="--------Boundary")
  78. ; Parameters ....: $File - The file path to upload
  79. ; $APIkey - your API key.
  80. ; $sBoundary - your Boundary.
  81. ; #FUNCTION# =============================================================================================
  82. Func VT_File_Scan($File,$APIkey,$sBoundary="--------Boundary")
  83. $sHeaders = "Content-Type: multipart/form-data; boundary=" & $sBoundary & @CRLF
  84. $sData = ''
  85. $sData &= "--" & $sBoundary & @CRLF
  86. $sData &= 'Content-Disposition: form-data; name="apikey"' & @CRLF & @CRLF & $APIkey & @CRLF
  87. $sData &= "--" & $sBoundary & @CRLF
  88. $sData &= __WinHttpFileContent("", "file", $File,$sBoundary)
  89. $sData &= "--" & $sBoundary & "--" & @CRLF
  90. return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/file/scan", Default, StringToBinary($sData,0), $sHeaders)
  91. EndFunc
  92. ; #FUNCTION# =============================================================================================
  93. ; Name...........: VT_File_Rescan
  94. ; Description ...: Rescan files in VirusTotal's file store
  95. ; Syntax.........: VT_File_Rescan($Resource,$APIkey)
  96. ; Parameters ....: $Resource - md5/sha1/sha256/CSV
  97. ; $APIkey - your API key.
  98. ; #FUNCTION# =============================================================================================
  99. Func VT_File_Rescan($Resource,$APIkey)
  100. return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/file/rescan", Default, "resource=" & $Resource &"&key=" & $APIkey)
  101. EndFunc
  102. ; #FUNCTION# =============================================================================================
  103. ; Name...........: VT_Put_Comment
  104. ; Description ...: Make a commnet on files and URLs
  105. ; Syntax.........: VT_Put_Comment($Resource,$APIkey)
  106. ; Parameters ....: $Resource - md5/sha1/sha256
  107. ; $APIkey - your API key.
  108. ; $Commnet - your Comment.
  109. ; #FUNCTION# =============================================================================================
  110. func VT_Put_Comment($Resource,$APIkey,$Comment)
  111. return _WinHttpSimpleRequest($hConnect, "POST", "/vtapi/v2/comments/put", Default, "resource=" & $Resource & _
  112. "&comment=" & $Comment & "&key=" & $APIkey)
  113. EndFunc

comments powered by Disqus