display DNS

Status
Niet open voor verdere reacties.

timseverien

Nieuwe gebruiker
Lid geworden
13 okt 2010
Berichten
1
Ik ben een DNS-cache viewer aan het maken voor educatieve doeleinden.

Ik probeer de gegevens binnen te halen door het commando "ipconfig /displaydns" uit te voeren.

Code:
Process p = new Process();

p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"c:\WINDOWS\system32\cmd.exe";
//p.StartInfo.FileName = @"c:\WINDOWS\system32\ipconfig.exe";

p.StartInfo.Arguments = "/c ipconfig /displaydns";
//p.StartInfo.Arguments = "/displaydns";

p.Start();

string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

devbox.Text = output;
(notities was een poging om het direct via ipconfig.exe uit te voeren)

Code:
1.0.0.127.in-addr.arpa
----------------------------------------
Recordnaam . . . . . : 1.0.0.127.in-addr.arpa.
Recordtype . . . . . : 12
Time-to-Live . . . . : 574790
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
PTR-record  . . . . : localhost


mail.google.com
----------------------------------------
Recordnaam . . . . . : mail.google.com
Recordtype . . . . . : 5
Time-to-Live . . . . : 52
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
CNAME-record  . . . : googlemail.l.google.com

localhost
----------------------------------------
Recordnaam . . . . . : localhost
Recordtype . . . . . : 1
Time-to-Live . . . . : 574790
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
A-record (host). . . : 127.0.0.1
(CMD.exe output - verkleint)

Code:
1.0.0.127.in-addr.arpa
----------------------------------------
Recordnaam . . . . . : 1.0.0.127.in-addr.arpa.
Recordtype . . . . . : 12
Time-to-Live . . . . : 574790
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
PTR-record  . . . . : localhost

localhost
----------------------------------------
Recordnaam . . . . . : localhost
Recordtype . . . . . : 1
Time-to-Live . . . . : 574790
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
A-record (host). . . : 127.0.0.1
(Applicatie output)

In plaats dat hij ALLE cache-items laat zien, laat hij (blijkbaar) alleen gegevens zien van lokale items ("localhost" en "1.0.0.127.in-addr.arpa.")

Dit weet ik doordat ik eerst in CMD het commando heb gebruikt en alle gegevens gaf, daarna mn applicatie geprobeerd die dus minder gegevens gaf, en daarna weer met CMD die alles gaf.

Hoe zit dat nou? Is het iets met rechten? Een code fout? Een parameter fout?
 
Laatst bewerkt:
[cpp]
static void Main(string[] args)
{
Process p = new Process();
try
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "c:\\windows\\system32\\ipconfig.exe";
p.StartInfo.Arguments = "/displaydns";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Console.WriteLine(output);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.Read();
}
[/cpp]

Met de bovenstaande code krijg ik gewoon dezelfde output als dat ik het commando los in cmd geef.

Windows IP-configuratie

aanbieding.helpmij.nl
----------------------------------------
Recordnaam . . . . . : aanbieding.helpmij.nl
Recordtype . . . . . : 1
Time-to-Live . . . . : 85531
Gegevenslengte . . . : 4
Sectie . . . . . . . : antwoord
A-record (host). . . : 212.79.247.24
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan