Hack Forums
[C#] Kleenscan API In CSharp - 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: [C#] Kleenscan API In CSharp (/showthread.php?tid=6126916)



Kleenscan API In CSharp - SIM-4704770 - Dec 11, 2020

I recently bought kleenscan and wanted to add it to my c# applications, here is the code I used.
Code
using(var httpClient = new HttpClient()) {
  using(var request = new HttpRequestMessage(new HttpMethod("POST"), "https://kleenscan.com/api/v1/file/scan")) {
    var multipartContent = new MultipartFormDataContent {
      {
        new ByteArrayContent(File.ReadAllBytes("your_file_path_here")),
        "path",
        Path.GetFileName("your_file_path_here")
      },
      {
        new StringContent("avast,avg"),
        "avList"
      }
    };
    request.Content = multipartContent;
    request.Headers.Add("X-Auth-Token", "Your Authentication Token Here");
    var response = await httpClient.SendAsync(request);
    string resp = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result).ToString();
  }
}
Successful response, containing the scan_token looks like this:
Code
"success" => true
"error_message" => "";
"data" => [
"scan_token" => "bc0890be7133616e68f5d81207cca045"
]
This is just for uploading files, which a lot of people seem to be having a hard time with. Getting avlist and results is easy enough.


RE: Kleenscan API In CSharp - neon_light - Dec 12, 2020

That's pretty nice! The kleenscan api is really nice to use, I'm using it for my free AV scanner website too!

One thing to keep in mind about this c# version is that if you include your api key in your application, other people will be able to extract it and use it themselves!


RE: Kleenscan API In CSharp - SIM-4704770 - Dec 12, 2020

Yeah I found that to be a problem, I'm adding it as a addon that you can purchase from kleenscan separately, or possibly I could make a deal with kleenscan where I get bulk accounts so that I can give every client their own personal key as part of purchasing my crypter.


RE: Kleenscan API In CSharp - neon_light - Dec 13, 2020

(Dec 12, 2020 09:20 AM)Mark Skith Wrote:  Yeah I found that to be a problem, I'm adding it as a addon that you can purchase from kleenscan separately, or possibly I could make a deal with kleenscan where I get bulk accounts so that I can give every client their own personal key as part of purchasing my crypter.

I mean, i doubt that kleenscan would go for this. The secure way of providing scans in your crypter is to do those scans server side on your own server.

This way you can easily limit scans per customer (based on their license id) to something like 100 scans per week, without giving away your kleenscan API key.


RE: Kleenscan API In CSharp - VisualSoft - Dec 13, 2020

Nice share,
will be helpful for many HF users.


RE: Kleenscan API In CSharp - SIM-4704770 - Dec 13, 2020

(Dec 13, 2020 01:47 AM)neon_light Wrote:  I mean, i doubt that kleenscan would go for this. The secure way of providing scans in your crypter is to do those scans server side on your own server.

This way you can easily limit scans per customer (based on their license id) to something like 100 scans per week, without giving away your kleenscan API key.

Well I believe that they would go for me just adding their api into it allowing for people to buy kleenscan and use it together with my products. I do get what your saying.


RE: Kleenscan API In CSharp - SIM-4725719 - Dec 21, 2020

(Dec 11, 2020 08:07 PM)Mark Skith Wrote:  I recently bought kleenscan and wanted to add it to my c# applications, here is the code I used.
Code
using(var httpClient = new HttpClient()) {
  using(var request = new HttpRequestMessage(new HttpMethod("POST"), "https://kleenscan.com/api/v1/file/scan")) {
    var multipartContent = new MultipartFormDataContent {
      {
        new ByteArrayContent(File.ReadAllBytes("your_file_path_here")),
        "path",
        Path.GetFileName("your_file_path_here")
      },
      {
        new StringContent("avast,avg"),
        "avList"
      }
    };
    request.Content = multipartContent;
    request.Headers.Add("X-Auth-Token", "Your Authentication Token Here");
    var response = await httpClient.SendAsync(request);
    string resp = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result).ToString();
  }
}
Successful response, containing the scan_token looks like this:
Code
"success" => true
"error_message" => "";
"data" => [
"scan_token" => "bc0890be7133616e68f5d81207cca045"
]
This is just for uploading files, which a lot of people seem to be having a hard time with. Getting avlist and results is easy enough.

thought you didn't have btc to refund me....


RE: Kleenscan API In CSharp - riu41776 - Dec 21, 2020

You're just uploading a PE to a remote cloud which runs a scan on their side using AVG and Avast (according to your params). Why not just reference people here to their api instead of writing a wrapper on top of it?


RE: Kleenscan API In CSharp - neon_light - Dec 21, 2020

(Dec 21, 2020 07:42 AM)riu41776 Wrote:  You're just uploading a PE to a remote cloud which runs a scan on their side using AVG and Avast (according to your params).

It's probably just meant as an example. Most people will stick with "all"


(Dec 21, 2020 07:42 AM)riu41776 Wrote:  Why not just reference people here to their api instead of writing a wrapper on top of it?


People that want to use the kleenscan API probably already know those API docs. People looking for help with c# examples probably just dont know how to use their api within C#, so an example like from OP could help them implement it.


RE: Kleenscan API In CSharp - kleenscan - Mar 6, 2021

Nice work, great job :)


RE: Kleenscan API In CSharp - SIM-4704770 - Mar 6, 2021

Yeah no problem, I didn't see it on your documentation area, so I just wanted it to be released somewhere, to help people who don't understand api usage in c#.