Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Windows Dragon

[Resolvido] Array JSON

Recommended Posts

Windows Dragon

Boas pessoal...

É o seguinte eu estou a tentar incorporar o VirusTotal com um dos meus programas... E para tal tenho que ler uma resposta em JSON

O que eu tenho até agora é:

	Dim val As String
	Dim req As HttpWebRequest = DirectCast(WebRequest.Create("https://www.virustotal.com/vtapi/v2/file/report"), HttpWebRequest)
	req.Method = "POST"
	req.ContentType = "application/x-www-form-urlencoded"
	val = "&resource=md5_do_ficheiro&key=public_key"
	req.ContentLength = val.Length
	Dim stOut As New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)
	stOut.Write(val)
	stOut.Close()	
	Dim stIn As New StreamReader(req.GetResponse().GetResponseStream())
	Dim strin As String = stIn.ReadToEnd()
	Dim JSON As JObject
	JSON = JObject.Parse(strin)

	Dim totalscans As String = Convert.ToString(JSON("total"))
	Dim positivescans As String = Convert.ToString(JSON("positives"))
	Dim link As String = Convert.ToString(JSON("permalink"))
	Dim ScanData As String = Convert.ToString(JSON("scan_date"))
	Dim SHA1 As String = Convert.ToString(JSON("sha1"))
	Dim MD5 As String = Convert.ToString(JSON("md5"))
	Dim SHA256 As String = Convert.ToString(JSON("sha256"))

	stIn.Close()

Até aqui 5* funciona uma maravilha... agora vem a parte dos scans que tem esta aparência

{
 "TotalDefense": {
"detected": false,
"version": "37.0.10100",
"result": null,
"update": "20121002"
 },
 "nProtect": {
"detected": false,
"version": "2012-10-02.01",
"result": null,
"update": "20121001"
 },
 "CAT-QuickHeal": {
"detected": false,
"version": "12.00",
"result": null,
"update": "20121001"
 },
 "McAfee": {
"detected": false,
"version": "5.400.0.1158",
"result": null,
"update": "20121002"
 },
 "K7AntiVirus": {
"detected": false,
"version": "9.153.7678",
"result": null,
"update": "20121002"
 },
 "TheHacker": {
"detected": false,
"version": "None",
"result": null,
"update": "20121001"
 },
 "F-Prot": {
"detected": false,
"version": "4.6.5.141",
"result": null,
"update": "20120926"
 },
 "Symantec": {
"detected": false,
"version": "20121.2.1.2",
"result": null,
"update": "20121002"
 },
 "Norman": {
"detected": false,
"version": "6.08.06",
"result": null,
"update": "20121002"
 },
 "ByteHero": {
"detected": false,
"version": "1.0.0.1",
"result": null,
"update": "20121002"
 },
 "TrendMicro-HouseCall": {
"detected": false,
"version": "9.700.0.1001",
"result": null,
"update": "20121002"
 },
 "Avast": {
"detected": false,
"version": "6.0.1289.0",
"result": null,
"update": "20121002"
 },
 "eSafe": {
"detected": false,
"version": "7.0.17.0",
"result": null,
"update": "20120927"
 },
 "ClamAV": {
"detected": false,
"version": "0.97.3.0",
"result": null,
"update": "20121001"
 },
 "Kaspersky": {
"detected": false,
"version": "9.0.0.837",
"result": null,
"update": "20121001"
 },
 "BitDefender": {
"detected": false,
"version": "7.2",
"result": null,
"update": "20121002"
 },
 "Agnitum": {
"detected": false,
"version": "5.5.1.3",
"result": null,
"update": "20121002"
 },
 "ViRobot": {
"detected": false,
"version": "2011.4.7.4223",
"result": null,
"update": "20121002"
 },
 "Sophos": {
"detected": false,
"version": "4.81.0",
"result": null,
"update": "20121002"
 },
 "Comodo": {
"detected": false,
"version": "13726",
"result": null,
"update": "20121002"
 },
 "F-Secure": {
"detected": false,
"version": "9.0.16440.0",
"result": null,
"update": "20121002"
 },
 "DrWeb": {
"detected": false,
"version": "7.0.3.07130",
"result": null,
"update": "20121002"
 },
 "VIPRE": {
"detected": false,
"version": "13336",
"result": null,
"update": "20121002"
 },
 "AntiVir": {
"detected": false,
"version": "7.11.44.234",
"result": null,
"update": "20121002"
 },
 "TrendMicro": {
"detected": false,
"version": "9.561.0.1028",
"result": null,
"update": "20121002"
 },
 "McAfee-GW-Edition": {
"detected": false,
"version": "2012.1",
"result": null,
"update": "20121001"
 },
 "Emsisoft": {
"detected": false,
"version": "5.1.0.11",
"result": null,
"update": "20120919"
 },
 "Jiangmin": {
"detected": false,
"version": "13.0.900",
"result": null,
"update": "20121001"
 },
 "Antiy-AVL": {
"detected": false,
"version": "2.0.3.7",
"result": null,
"update": "20121001"
 },
 "Kingsoft": {
"detected": false,
"version": "2012.9.4.139",
"result": null,
"update": "20120925"
 },
 "Microsoft": {
"detected": false,
"version": "1.8800",
"result": null,
"update": "20121002"
 },
 "SUPERAntiSpyware": {
"detected": false,
"version": "5.50.0.1016",
"result": null,
"update": "20120911"
 },
 "GData": {
"detected": false,
"version": "22",
"result": null,
"update": "20121002"
 },
 "Commtouch": {
"detected": false,
"version": "5.3.2.6",
"result": null,
"update": "20121002"
 },
 "AhnLab-V3": {
"detected": false,
"version": "2012.10.03.00",
"result": null,
"update": "20121002"
 },
 "VBA32": {
"detected": false,
"version": "3.12.18.2",
"result": null,
"update": "20121001"
 },
 "PCTools": {
"detected": false,
"version": "8.0.0.5",
"result": null,
"update": "20121002"
 },
 "ESET-NOD32": {
"detected": false,
"version": "7538",
"result": null,
"update": "20121002"
 },
 "Rising": {
"detected": false,
"version": "24.29.05.01",
"result": null,
"update": "20120928"
 },
 "Ikarus": {
"detected": false,
"version": "T3.1.1.122.0",
"result": null,
"update": "20121002"
 },
 "Fortinet": {
"detected": false,
"version": "5.0.26.0",
"result": null,
"update": "20121002"
 },
 "AVG": {
"detected": false,
"version": "10.0.0.1190",
"result": null,
"update": "20121002"
 },
 "Panda": {
"detected": false,
"version": "10.0.3.5",
"result": null,
"update": "20121001"
 }
}

E não quero definir isto tudo à mão... Estava á espera de poder usar o For Each... Mas não estou a ver como.

Eu obtive esta resposta com o este código

Convert.ToString(JSON("scans"))

Alguma ajuda?

Edited by Windows Dragon

Share this post


Link to post
Share on other sites
thoga31

resolvido

E como resolveste? Convinha ficar aqui a solução para referência futura...


Knowledge is free!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.