Skip to content

Instantly share code, notes, and snippets.

@Shaked
Created October 6, 2019 11:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaked/c7620056a28b088996dd91d2fcb628bf to your computer and use it in GitHub Desktop.
Save Shaked/c7620056a28b088996dd91d2fcb628bf to your computer and use it in GitHub Desktop.
SSRF ideas?
<?php
$url = $_GET['url'];
$xml = @file_get_contents($url);
$ret = [];
if ($xml) {
$doc = new DOMDocument();
libxml_use_internal_errors(true);
if ($doc->loadHTML($xml)) {
$title = $doc->getElementsByTagName('title');
foreach ($title as $key => $value) {
$ret['title'] = $value->nodeValue;
}
$meta = $doc->getElementsByTagName('meta');
foreach ($meta as $key => $value) {
$property = $value->getAttribute('property');
if ($property == 'og:image') {
$ret['image'] = $value->getAttribute('content');
break;
}
}
}
} else {
$ret['error'] = "could not parse url $url";
}
echo json_encode($ret);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment