Hack Forums
[Python] Kleenscan API Scanner - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Kleenscan API Scanner (/showthread.php?tid=6207803)



Kleenscan API Scanner - Mr Roboto - Jun 1, 2022

Hello everyone,

I coded this tool in order to ease the scanning progress and wanted to contribute more to this website.

Scans with 19 antiviruses - Adaware, Amiti, Arcabit, Avast, AVG, Bitdefender, Comodo, Fsecure, Immunet, Sophos, Clamav, Norman, Bullguard, Gdata, Kaspersky, Maxsecure, Mcafee, Nod32 and Microsoft Defender.

Prerequisites
Kleenscan account
Requests library (use pip install)

Code
from requests import get, post
from os.path import isfile
from json import loads
from time import sleep

TOKEN = "your token here"


def main():
    prog = input("Enter program name > ")

    if not isfile(prog):
        print("Invalid file!")
        main()
        return

    prog = {"path": open(prog, "rb")}
    data = {"avList": "adaware,amiti,arcabit,avast,avg,bitdefender,comodo,fsecure,immunet,sophos,clamav,norman,"
                      "bullguard,gdata,kaspersky,maxsecure,mcafee,nod32,microsoftdefender"}

    print("Uploading file..")

    req = post("https://kleenscan.com/api/v1/file/scan", files=prog, data=data, headers={"X-Auth-Token": TOKEN})
    req = req.text

    if "account balance" in req:
        print("Can't scan - account balance is too low.")
        return

    scan_token = req.find("scan_token")

    if scan_token == -1:
        print("Something went wrong! No scan token.")
        return

    scan_token += 13
    scan_token = req[scan_token:len(req)-3]

    print("Sleeping for a bit for scans to complete..")
    sleep(25)

    req = get(f"https://kleenscan.com/api/v1/file/result/{scan_token}", headers={"X-Auth-Token": TOKEN})
    result = loads(req.text)["data"]

    num_detected = 0
    total_scans = 0

    for data in result:

        total_scans += 1

        avname = data["avname"][0].upper() + data["avname"][1:]
        status = data["status"]
        flagname = data["flagname"]

        if status != "ok":
            print(f"AV: {avname} -> Could not scan")
        else:
            print(f"AV: {avname} -> {flagname}")

        if flagname != "Undetected":
            num_detected += 1

    print(f"Total: {str(num_detected)}/{str(total_scans)}")


main()

[Image: e7o4YbW.png]

To use, just edit the TOKEN variable with your API token at the top of the file, place your PE in the same directory and type in the file name.

Hope this helps.