Skip to content

Commit

Permalink
Merge pull request #5 from sensepost/dev
Browse files Browse the repository at this point in the history
Disable RPC/HTTP code-path, this is not ready yet
  • Loading branch information
staaldraad authored Sep 28, 2016
2 parents 907e98c + 79ef8ce commit 8ceae2c
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func sendMail() {
*/
}

func getMapiHttp(autoURLPtr string) *utils.AutodiscoverResp {
func getMapiHTTP(autoURLPtr string) *utils.AutodiscoverResp {
var resp *utils.AutodiscoverResp
var err error
fmt.Println("[*] Retrieving MAPI/HTTP info")
Expand All @@ -60,7 +60,7 @@ func getMapiHttp(autoURLPtr string) *utils.AutodiscoverResp {
return resp
}

func getRpcHttp(autoURLPtr string) *utils.AutodiscoverResp {
func getRPCHTTP(autoURLPtr string) *utils.AutodiscoverResp {
var resp *utils.AutodiscoverResp
var err error
fmt.Println("[*] Retrieving RPC/HTTP info")
Expand Down Expand Up @@ -105,7 +105,8 @@ func main() {
conscPtr := flag.Int("attempts", 2, "Number of attempts before delay")
delayPtr := flag.Int("delay", 5, "Delay between attempts")
autoSendPtr := flag.Bool("send", false, "Autosend an email once the rule has been created")
//pwnPtr := flag.Bool("pwn", false, "Used in conjuction with --rule. This will send an email from the victim to themself to trigger the rule")
//createfPtr := flag.Bool("cf", false, "create a folder")

flag.Parse()

if *domainPtr == "" && *autoURLPtr == "" {
Expand Down Expand Up @@ -134,22 +135,22 @@ func main() {

if *autodiscoverOnly == true {

resp = getRpcHttp(*autoURLPtr)
resp = getRPCHTTP(*autoURLPtr)
fmt.Printf("[*] Autodiscover enabled and we could Authenticate.\nAutodiscover returned: %s", resp.Response.User)
os.Exit(0)

}

if *tcpPtr == false {
resp = getMapiHttp(*autoURLPtr)
resp = getMapiHTTP(*autoURLPtr)
mapiURL := mapi.ExtractMapiURL(resp)
if mapiURL == "" {
exit(fmt.Errorf("[x] No MAPI URL found. Exiting"))
//try RPC
fmt.Println("[x] No MAPI URL found. Trying RPC/HTTP")
resp = getRpcHttp(*autoURLPtr)
fmt.Println(resp.Response.Account.Protocol[0].Server)
mapi.Init(config, resp.Response.User.LegacyDN, "", mapi.RPC)
//exit(fmt.Errorf("[x] No MAPI URL found. Exiting"))
//fmt.Println("[x] No MAPI URL found. Trying RPC/HTTP")
//resp = getRPCHTTP(*autoURLPtr)
//fmt.Println(resp.Response.Account.Protocol[0].Server)
//mapi.Init(config, resp.Response.User.LegacyDN, "", mapi.RPC)
}
fmt.Println("[+] MAPI URL found: ", mapiURL)
if *checkOnly == true {
Expand All @@ -158,9 +159,12 @@ func main() {
}
mapi.Init(config, resp.Response.User.LegacyDN, mapiURL, mapi.HTTP)
} else {
resp = getRpcHttp(*autoURLPtr)
fmt.Println(resp.Response.Account.Protocol[0].Server)
mapi.Init(config, resp.Response.User.LegacyDN, "", mapi.RPC)
exit(fmt.Errorf("[x] RPC/HTTP not yet supported. "))
/*
resp = getRPCHTTP(*autoURLPtr)
fmt.Println(resp.Response.Account.Protocol[0].Server)
mapi.Init(config, resp.Response.User.LegacyDN, "", mapi.RPC)
*/
}

logon, err := mapi.Authenticate()
Expand All @@ -171,24 +175,17 @@ func main() {
fmt.Printf("[+] Mailbox GUID: %x\n", logon.MailboxGUID)
fmt.Println("[*] Openning the Inbox")

propertyTags := make([]mapi.PropertyTag, 8)
propertyTags[0] = mapi.PidTagParentFolderID
propertyTags[1] = mapi.PidTagAccess
propertyTags[2] = mapi.PidTagMemberName
propertyTags[3] = mapi.PidTagDefaultPostMessageClass
propertyTags[4] = mapi.PidTagDisplayName
propertyTags[5] = mapi.PidTagFolderType
propertyTags[6] = mapi.PidTagContentCount
propertyTags[7] = mapi.PidTagSubfolders

propertyTags := make([]mapi.PropertyTag, 2)
propertyTags[0] = mapi.PidTagDisplayName
propertyTags[1] = mapi.PidTagSubfolders
mapi.GetFolder(mapi.INBOX, propertyTags) //Open Inbox

//Display All rules
if *displayRules == true {
fmt.Println("[+] Retrieving Rules")
rules, err := mapi.DisplayRules()
if err != nil {
exit(err)
rules, er := mapi.DisplayRules()
if er != nil {
exit(er)
}
fmt.Printf("[+] Found %d rules\n", len(rules))
for _, v := range rules {
Expand All @@ -206,9 +203,9 @@ func main() {
err = mapi.ExecuteMailRuleDelete(ruleid)
if err == nil {
fmt.Println("[*] Rule deleted. Fetching list of remaining rules...")
rules, err := mapi.DisplayRules()
if err != nil {
exit(err)
rules, er := mapi.DisplayRules()
if er != nil {
exit(er)
}
fmt.Printf("[+] Found %d rules\n", len(rules))
for _, v := range rules {
Expand Down

0 comments on commit 8ceae2c

Please sign in to comment.