Skip to content

Instantly share code, notes, and snippets.

@kounelios13
Created September 17, 2020 12:59
Show Gist options
  • Save kounelios13/2d191b04ac294587ba9fa1fb639457a4 to your computer and use it in GitHub Desktop.
Save kounelios13/2d191b04ac294587ba9fa1fb639457a4 to your computer and use it in GitHub Desktop.
Parsing xml string
package main
import (
"fmt"
"encoding/xml"
)
type Example struct{
XMLName xml.Name `xml:"Example"`
Markup []string `xml:"xhtml"`
Paragraphs []string `xml:"xhtml:p"`
Divs []string `xml:"xhtml:div"`
}
func main() {
x:= "<Example><xhtml:p>A victim has an authenticated session with a site that provides an electronic payment service to transfer funds between subscribing members. At the same time, the victim receives an e-mail that appears to come from an online publication to which they subscribe with links to today's news articles. The victim clicks on one of these links and is taken to a page with the news story. There is a screen with an advertisement that appears on top of the news article with the 'skip this ad' button. Eager to read the news article, the user clicks on this button. Nothing happens. The user clicks on the button one more time and still nothing happens.</xhtml:p><xhtml:div>In reality, the victim activated a hidden action control located in a transparent layer above the 'skip this ad' button. The ad screen blocking the news article made it likely that the victim would click on the 'skip this ad' button. Clicking on the button, actually initiated the transfer of $1000 from the victim's account with an electronic payment service to an adversary's account. Clicking on the 'skip this ad' button the second time (after nothing seemingly happened the first time) confirmed the transfer of funds to the electronic payment service.</xhtml:div></Example>"
b := []byte(x)
var a Example
xml.Unmarshal(b,&a)
fmt.Printf("%+v",a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment