所有,我真的可以在這裏使用一些幫助。我的最終目標是能夠使用perl讀取xml文件,並將其插入數據庫以跟蹤CVE。在這個階段,如果我只能從我的代碼中的XML文件中引用變量,我相信我可以將它插入到數據庫中。現在我所要做的就是把它打印到屏幕上,但我無法使它正常工作。使用Perl XML解析XML與命名空間::簡單
這是我簡單的代碼和XML文件。
希望有人能讓我去這裏。
的Perl --start代碼 -
#!/usr/bin/perl
# use module
use XML::Simple;
use Data::Dumper;
# create object
xml = new XML::Simple (KeyAttr=>[]);
# read XML file
#$data = $xml->XMLin("tms.xml");
# print output - used this to see if it was even reading it
#print Dumper($data);
# access XML data
print "Here is the BugTrackID: $data->{'x:BugTraqID'}\n";
Perl代碼--end ---
的xml--
<?xml version="1.0" encoding="us-ascii"?>
<Alerts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:alerts.symantec.com https://alerts.symantec.com/vulalert.xsd">
<x:AlertDocument xmlns:x="urn:alerts.symantec.com" AlertStatusID="57982" Type="1" DetailLevel="25" Language="1">
<x:BugTraqID>57982</x:BugTraqID>
<x:Title>Sonar Multiple Cross Site Scripting Vulnerabilities</x:Title>
<x:StatusID>1</x:StatusID>
<x:CVE>CVE-MAP-NOMATCH</x:CVE>
<x:Published>Feb 12 2013</x:Published>
<x:LastUpdated>2013-02-15T19:03:48</x:LastUpdated>
<x:Remote>Yes</x:Remote>
<x:Local>No</x:Local>
<x:Credibility>Single Source</x:Credibility>
<x:Classification>Input Validation Error</x:Classification>
<x:Availability>User Initiated</x:Availability>
<x:Ease>Exploit Available</x:Ease>
<x:Authentication>Not Required</x:Authentication>
<x:CVSS2_BaseScore>5.8</x:CVSS2_BaseScore>
<x:CVSS2_TemporalScore>5</x:CVSS2_TemporalScore>
<x:CVSS2_BaseVector>AV:N/AC:M/Au:N/C:P/I:P/A:N</x:CVSS2_BaseVector>
<x:CVSS2_TemporalVector>E:F/RL:U/RC:UC</x:CVSS2_TemporalVector>
<x:CVSS1_BaseScore>3.7</x:CVSS1_BaseScore>
<x:CVSS1_TemporalScore>3.2</x:CVSS1_TemporalScore>
<x:NVD_CVSS2_BaseScore>4.3</x:NVD_CVSS2_BaseScore>
<x:NVD_CVSS2_ComponentString>AV:N/AC:M/Au:N/C:N/I:P/A:N</x:NVD_CVSS2_ComponentString>
<x:ImpactRating>4</x:ImpactRating>
<x:Severity>6.1</x:Severity>
<x:EaseofExploit>8</x:EaseofExploit>
<x:UrgencyRating>6.1</x:UrgencyRating>
<x:LastChange>Initial analysis.</x:LastChange>
<x:VulnerableSystems>
<x:VulnerableSystem>
<x:Title><![CDATA[SonarSource Sonar 3.4.1 cpe:/a:sonarsource:sonar:3.4.1 SYMC]]></x:Title>
</x:VulnerableSystem>
</x:VulnerableSystems>
<x:ShortSummary><![CDATA[Sonar is prone to multiple cross-site scripting vulnerabilities.]]></x:ShortSummary>
<x:Impact>An attacker may leverage these issues to execute arbitrary script code in the browser of an unsuspecting user in the context of the affected site. This may allow the attacker to steal cookie-based authentication credentials and launch other attacks.</x:Impact>
<x:TechnicalDescription><![CDATA[Sonar is the open source platform for code quality inspection.
The application is prone to multiple cross-site scripting vulnerabilities because it fails to sanitize user-supplied input submitted to the following scripts and parameters:
'index.php ' : 'search', 'assignee_login',
'author_login'
'sources.php' : 'resource'
An attacker may leverage these issues to execute arbitrary script code in the browser of an unsuspecting user in the context of the affected site. This may allow the attacker to steal cookie-based authentication credentials and launch other attacks.
Sonar 3.4.1 is vulnerable; other versions may also be affected.]]>
</x:TechnicalDescription>
<x:AttackScenario><![CDATA[1. An attacker scans for and locates a site running the affected application.
2. The attacker crafts a URI link that includes malicious script code designed to leverage one of these issues.
3. The attacker uses email or other means to distribute the malicious link and entices an unsuspecting user to follow it.
4. When the user follows the link, the attacker-specified script code runs in their browser in the context of the affected site.
A successful exploit may let the attacker steal cookie-based authentication credentials and launch other attacks.]]></x:AttackScenario>
<x:Exploit><![CDATA[Attackers can exploit these issues by enticing an unsuspecting victim into following a malicious URI.
The following example URIs are available:
http://www.example.com/dependencies/index? search="&gt;&lt;script&gt;alert(/devilteam.pl/)&lt;/script&gt;
http://www.example.com/dashboard/index/41730? did=4&amp;period=3"&gt;&lt;script&gt;alert(/devilteam.pl/)&lt;/script&am p;gt;
http://www.example.com/reviews/index?review_id=&amp;statuses[]=OPEN&amp;statuses[]=REOPENED&amp;severities[]=&amp;projects[]=&amp;amp;author_login=&amp;assignee_login="&gt;&lt;script&gt;alert(/devilteam.pl/)&lt;/script&gt;&amp;false_positives=without&amp;sort=&amp;asc=false&amp;commit=Search
http://www.example.com/reviews/index?review_id=&amp;statuses[]=OPEN&amp;statuses[]=REOPENED&amp;severities[]=&amp;projects[]=&amp;amp;author_login="&gt;&lt;script&gt;alert(/devilteam.pl/)&lt;/script&gt;&amp;assignee_login=&amp;false_positives=without&amp;sort=&amp;asc=false&amp;commit=Search
http://www.example.com/api/sources?resource=&lt;script&gt;alert(/devilteam.pl/)&lt;/script&gt;&amp;format=txt
]]></x:Exploit>
<x:MitigatingStrategies>
<x:MitigatingStrategy>
<x:Title><![CDATA[Block external access at the network boundary, unless external parties require service.]]></x:Title>
<x:Description><![CDATA[If global access isn't needed, filter access to the affected computer at the network boundary. Restricting access to only trusted computers and networks might greatly reduce the likelihood of a successful exploit.]]></x:Description>
</x:MitigatingStrategy>
<x:MitigatingStrategy>
<x:Title><![CDATA[Run all software as a nonprivileged user with minimal access rights.]]></x:Title>
<x:Description><![CDATA[Attackers may successfully exploit client flaws in the browser through cross-site scripting vulnerabilities. When possible, run client software as regular user accounts with limited access to system resources. This may limit the immediate consequences of client-side vulnerabilities. ]]></x:Description>
</x:MitigatingStrategy>
<x:MitigatingStrategy>
<x:Title><![CDATA[Do not follow links provided by unknown or untrusted sources.]]></x:Title>
<x:Description><![CDATA[Web users should be cautious about following links to websites that are provided by unfamiliar or suspicious sources. Filtering HTML from emails may help remove a possible vector for transmitting malicious links to users. ]]></x:Description>
</x:MitigatingStrategy>
<x:MitigatingStrategy>
<x:Title><![CDATA[Set web browser security to disable the execution of script code or active content.]]></x:Title>
<x:Description><![CDATA[Since exploiting cross-site scripting issues often requires malicious script code to run in browsers, consider disabling script code and active content support within a client browser as a way to prevent a successful exploit. Note that this mitigation tactic might adversely affect legitimate sites that rely on the execution of browser-based script code. ]]></x:Description>
</x:MitigatingStrategy>
</x:MitigatingStrategies>
<x:Solutions>
<x:Workaround><![CDATA[Workaround
]]></x:Workaround>
<x:Solution><![CDATA[Currently, we are not aware of any vendor-supplied patches. If you feel we are in error or are aware of more recent information, please mail us at: [email protected]]]></x:Solution>
</x:Solutions>
<x:Credit>DevilTeam</x:Credit>
<x:ChangeLogs>
<x:ChangeLog>
<x:Title><![CDATA[2013.02.15: Initial analysis.]]></x:Title>
</x:ChangeLog>
</x:ChangeLogs>
<x:References>
<x:Reference>
<x:Title><![CDATA[Web Page:Sonar Homepage (SonarSource) SonarSource]]></x:Title>
<x:URL><![CDATA[http://www.sonarsource.com/products/software/sonar/]]></x:URL>
<x:Description><![CDATA[http://www.sonarsource.com/products/software/sonar/]]></x:Description>
</x:Reference>
<x:Reference>
<x:Title><![CDATA[Web Page:Sonar v.3.4.1 =&gt; XSS (CWE-79) (DevilTeam) DevilTeam]]></x:Title>
<x:URL><![CDATA[http://cxsecurity.org/issue/WLB-2013020088]]></x:URL>
<x:Description><![CDATA[http://cxsecurity.org/issue/WLB-2013020088]]></x:Description>
</x:Reference>
</x:References>
<x:URL>https://alerts.symantec.com/loaddocument.aspx?GUID=cffd18f0-7b75-4c6a-adc0-74f480808fff</x:URL>
<x:OVALDefinitions />
</x:AlertDocument>
</Alerts>
的--end --start xml ---
你有什麼問題? – ikegami 2013-02-16 03:42:20
你提到了namesapces。 XML :: Simple知道關於namespsaces和前綴的事情。它只是假定前綴是節點名稱的一部分。 「XML :: Simple,您可以使用的最複雜的XML解析器。」 – ikegami 2013-02-16 03:43:34
我無法讓它輸出任何值。具體來說,我只是試圖讓它從xml文件打印bugtraqid值。它回來了。 – 2013-02-16 03:45:46