filtrar ou consultar XML [RESOLVIDO]

1. filtrar ou consultar XML [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 19/04/2011 - 09:31h

desse arquivo inteiro

================
douglas@Douglao:~$ cat DGFCRACKWIFI.cap-01.kismet.netxml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE detection-run SYSTEM "http://kismetwireless.net/kismet-3.1.0.dtd">

<detection-run kismet-version="airodump-ng-1.0" start-time="Tue Apr 19 08:04:02 2011">

<wireless-network number="1" type="infrastructure" first-time="Tue Apr 19 08:04:06 2011" last-time="Tue Apr 19 08:18:23 2011">
<SSID first-time="Tue Apr 19 08:04:06 2011" last-time="Tue Apr 19 08:18:23 2011">
<type>Beacon</type>
<max-rate>54.000000</max-rate>
<packets>12</packets>
<beaconrate>10</beaconrate>
<encryption>WPA TKIP </encryption>
<essid cloaked="false">residence wireless</essid>
</SSID>
<BSSID>00:1C:DF:CC:97:4E</BSSID>
<manuf>Unknown</manuf>
<channel>1</channel>
<freqmhz>2412 21</freqmhz>
<maxseenrate>54000</maxseenrate>
<packets>
<LLC>12</LLC>
<data>0</data>
<crypt>0</crypt>
<total>21</total>
<fragments>0</fragments>
<retries>0</retries>
</packets>
<datasize>0</datasize>
<snr-info>
<last_signal_dbm>0</last_signal_dbm>
<last_noise_dbm>0</last_noise_dbm>
<last_signal_rssi>0</last_signal_rssi>
<last_noise_rssi>0</last_noise_rssi>
<min_signal_dbm>0</min_signal_dbm>
<min_noise_dbm>0</min_noise_dbm>
<min_signal_rssi>1024</min_signal_rssi>
<min_noise_rssi>1024</min_noise_rssi>
<max_signal_dbm>0</max_signal_dbm>
<max_noise_dbm>0</max_noise_dbm>
<max_signal_rssi>0</max_signal_rssi>
<max_noise_rssi>0</max_noise_rssi>
</snr-info>
<bsstimestamp>0</bsstimestamp>
<cdp-device></cdp-device>
<cdp-portid></cdp-portid>
</wireless-network>
<wireless-network number="2" type="infrastructure" first-time="Tue Apr 19 08:04:06 2011" last-time="Tue Apr 19 08:18:23 2011">
<SSID first-time="Tue Apr 19 08:04:06 2011" last-time="Tue Apr 19 08:18:23 2011">
<type>Beacon</type>
<max-rate>54.000000</max-rate>
<packets>12</packets>
<beaconrate>10</beaconrate>
<encryption>WPA TKIP </encryption>
<essid cloaked="false">MarcosGSIlva</essid>
</SSID>
<BSSID>00:1B:11:EE:32:D2</BSSID>
<manuf>Unknown</manuf>
<channel>1</channel>
<freqmhz>2412 16</freqmhz>
<maxseenrate>54000</maxseenrate>
<packets>
<LLC>12</LLC>
<data>0</data>
<crypt>0</crypt>
<total>16</total>
<fragments>0</fragments>
<retries>0</retries>
</packets>
<datasize>0</datasize>
<snr-info>
<last_signal_dbm>0</last_signal_dbm>
<last_noise_dbm>0</last_noise_dbm>
<last_signal_rssi>0</last_signal_rssi>
<last_noise_rssi>0</last_noise_rssi>
<min_signal_dbm>0</min_signal_dbm>
<min_noise_dbm>0</min_noise_dbm>
<min_signal_rssi>1024</min_signal_rssi>
<min_noise_rssi>1024</min_noise_rssi>
<max_signal_dbm>0</max_signal_dbm>
<max_noise_dbm>0</max_noise_dbm>
<max_signal_rssi>0</max_signal_rssi>
<max_noise_rssi>0</max_noise_rssi>
</snr-info>
<bsstimestamp>0</bsstimestamp>
<cdp-device></cdp-device>
<cdp-portid></cdp-portid>
</wireless-network>
<wireless-network number="3" type="infrastructure" first-time="Tue Apr 19 08:04:04 2011" last-time="Tue Apr 19 08:18:24 2011">
<SSID first-time="Tue Apr 19 08:04:04 2011" last-time="Tue Apr 19 08:18:24 2011">
<type>Beacon</type>
<max-rate>54.000000</max-rate>
<packets>62</packets>
<beaconrate>10</beaconrate>
<encryption>WPA2 WPA AES-CCM </encryption>
<essid cloaked="false">TP-LINK-DODE</essid>
</SSID>
<BSSID>D8:5D:4C:B2:B1:44</BSSID>
<manuf>Unknown</manuf>
<channel>3</channel>
<freqmhz>2422 172</freqmhz>
<maxseenrate>54000</maxseenrate>
<packets>
<LLC>62</LLC>
<data>3</data>
<crypt>0</crypt>
<total>172</total>
<fragments>0</fragments>
<retries>0</retries>
</packets>
<datasize>0</datasize>
<snr-info>
<last_signal_dbm>0</last_signal_dbm>
<last_noise_dbm>0</last_noise_dbm>
<last_signal_rssi>0</last_signal_rssi>
<last_noise_rssi>0</last_noise_rssi>
<min_signal_dbm>0</min_signal_dbm>
<min_noise_dbm>0</min_noise_dbm>
<min_signal_rssi>1024</min_signal_rssi>
<min_noise_rssi>1024</min_noise_rssi>
<max_signal_dbm>0</max_signal_dbm>
<max_noise_dbm>0</max_noise_dbm>
<max_signal_rssi>0</max_signal_rssi>
<max_noise_rssi>0</max_noise_rssi>
</snr-info>
<bsstimestamp>0</bsstimestamp>
<cdp-device></cdp-device>
<cdp-portid></cdp-portid>
</wireless-network>
</detection-run>

================

só quero essas informações

==================

residence wireless
00:1C:DF:CC:97:4E
MarcosGSIlva
00:1B:11:EE:32:D2
TP-LINK-DODE
D8:5D:4C:B2:B1:44
====================

eu consegui assim

$ cat DGFCRACKWIFI.cap-01.kismet.netxml | grep "essid\|BSSID" | sed 's/essid\|BSSID//g;s/<\|>\|=\|"//g;s/\///g;s/cloaked\|false//g;'

mas é muita coisa, acredito que tenha alguma forma bem melhor que a minha

o xml tem algum tipo de consulta?


  


2. MELHOR RESPOSTA

Sandro Marcell
SMarcell

(usa Slackware)

Enviado em 20/04/2011 - 10:52h

Não melhorou muito =P mas o resultado é o mesmo:

$ sed -ne '/<essid .*>/{ s/.*>\(.*\)<.*/\1/; h }' -e '/<BSSID>/{ s/.*>\(.*\)<.*/\1/; H; g; p}' DGFCRACKWIFI.cap-01.kismet.net.xml
residence wireless
00:1C:DF:CC:97:4E
MarcosGSIlva
00:1B:11:EE:32:D2
TP-LINK-DODE
D8:5D:4C:B2:B1:44

Você também pode utilizar o Perl com o módulo 'XML::Simple' e pegar os valores pretendidos via arrays indexados.

3. Re: filtrar ou consultar XML [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 19/04/2011 - 21:21h

tem como converter o xml para um outro formato, tipo, com outro padrão/organização, pois pode ser mais facil de filtrar


4. Re: filtrar ou consultar XML [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 20/04/2011 - 18:34h

muito bom, vlw

o python tem algo semelhante a esse do perl??


5. Re: filtrar ou consultar XML [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 20/04/2011 - 18:59h

teria tbm como exibir os dois na mesma linha?

ex:
residence wireless 00:1C:DF:CC:97:4E
MarcosGSIlva 00:1B:11:EE:32:D2
TP-LINK-DODE D8:5D:4C:B2:B1:44

o endereço MAC na mesma linha do nome


6. Re: filtrar ou consultar XML [RESOLVIDO]

Sandro Marcell
SMarcell

(usa Slackware)

Enviado em 20/04/2011 - 21:39h

Sim, basta fazer uma pequena alteração:

sed -ne '/<essid .*>/{ s/.*>\(.*\)<.*/\1/; h }' -e '/<BSSID>/{ s/.*>\(.*\)<.*/\1/; H; g }' -e 's/\n/ /p'

Quanto ao Python, pesquise sobre 'minidom' e 'ElementTree'.


7. Re: filtrar ou consultar XML [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 20/04/2011 - 21:50h

isso ae, muito bom, vlw msm






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts