Monday, January 26, 2015

Hooked-Browser Meshed-Networks with WebRTC (Kiwicon 2014) - Part 2

In Part 1, we introduced you to BeEF's WebRTC extension as a solution for avoiding tracking of post-exploitation communication back to our BeEF server. In this post, we'll talk more about how this can be used during penetration testing. This will include further information about the extension and usage details for the console and RESTful API.

One of the pre-requisites of WebRTC is the ability for peers to share Session Description Protocol (SDP) signaling messages between each other. This nominates what TCP/UDP ports are available to receive data, video and audio channels. The WebRTC spec does NOT dictate how these signaling messages are passed between peers. So, we've implemented a signaling channel within BeEF - hence, you have to hook the browsers at least once.

Once signaling has been established, and the peers (1 to 1) are established, there are new JavaScript methods available to send messages to each other. If the peers are on the same subnet, they will in fact be sending DTLS (Datagram TLS) messages between each other directly over either TCP or UDP. If they're separated by Firewalls/NAT devices, there are methods available to WebRTC to get around this too.

A quick example. If browser 1 and 2 are peered, the following JavaScript will send a data channel message from browser 1 to browser 2:

Within beef.webrtc are event handlers for these messages. The following logic is currently in place:
  • If a peer receives a message of '!gostealth' - It will STOP talking to BeEF, and instead start polling back to its peer with a heartbeat. At this point, the browser will cease sending HTTP GET requests to the BeEF server, although is still peer-connected to another hooked-browser.
  • If a peer receives a message of '!endstealth' - It will come out of stealth, and start talking to BeEF again, but will still maintain the peer channel.
  • If a peer receives a message of '%<JavaScript>' - It will execute the JavaScript - sending any return values back to its peer (Not to BeEF directly), once this message is received it will then be sent back to BeEF.
  • If a peer is STEALTHED and receives any other message, it will simply replay the text back to the peer that stealthed made it go into stealth. Otherwise, it will send the message back to BeEF.
If you enable the WebRTC extension in BeEF, this functionality is available through the interactive console, and the RESTful API. 

Console usage:

BeEF> rtcgo 1 2

Will connect online browser 1 to 2. After connection, you will see event messages in the log (particularly if you started beef with -v)

BeEF> rtcgo 1 2 true

As above, but will print verbose messages in the clients' consoles

BeEF> rtcstatus 1

Will check the RTC statuses of the browser and its peers

BeEF> rtcmsg 1 2 "Hi browser 2 .. from browser 1"

Will tell browser 1 to send a datachannel message to browser 2

This will simply send a text message from 1 to 2, when 2 receives the message, it will send it back to BeEF and display in the log. 

There are a few custom datachannel message commands that are implemented within the client-side JS

BeEF> rtcmsg 1 2 !gostealth

This will tell browser 1 to command browser 2 to go into a stealth mode, which will make it stop talking to beef but remain connected to each other via WebRTC. Browser 2 will occasionally send a heartbeat back to browser 1 - which will be displayed in the beef log.

BeEF> rtcmsg 1 2 "%return window.prompt(\"test\");"

This will tell browser 1 to command browser 2 to execute the JavaScript, and return the value back to browser 1, who will then send it back to the beef log. This is especially useful in stealth mode, as you can still control the browser even though it's not talking to beef.

BeEF> rtcmsg 1 2 !endstealth

Will make browser 1 command browser 2 to come out of stealth, and will start talking to beef again.

While a browser is stealthed, it can't be seen from beef, and can't be used as the source of RTC messages (because these are passed to the browser via the hook.js polling process).

The RESTful API calls are similar and examples exist within extensions/webrtc/rest/webrtc.rb file. Functions include:
GET /api/webrtc/status/:id
POST /api/webrtc/go {"from":1,"to":2}
And the video demo is available

I'll be capturing some of this information within the Wiki soon as well -

Thanks for all your help and inspiration browser-peeps!



  1. This is very, very interesting! Thank you. Hope to see more.

  2. Managing the server is not an easy job it will take time, effort and lots of education/knowledge before you can fully manage network errors. Students from term paper writing service GhostProfessors will really appreciate it we share this network testing.

  3. I as of late had an astonishing chance to present this at Kiwicon 2014, and I was quick to get the code into BeEF. This blog entry gives a brief rundown of WebRTC and how it functions.
    best essay writing service

  4. Thanks for posting this useful custom tshirts content, Good to know about new things here, Let me share this, .

  5. This comment has been removed by the author.

  6. Making use of collection custom t shirt canada processing computer software effectively is surely an important quandary expertise to view. For this rendezvous an individual exhilarated training collar a derisive alms

  7. Really very interesting post!!
    I hope title is the most Second home attractive section of this particular post. I must read it. Sure I will book mark this content for the easy access of such an informative post.

  8. Hey!
    I as of late had an astonishing chance to present this at Kiwicon 2014, and I was quick heating pad to get the code into BeEF. This blog entry gives a brief rundown of WebRTC and how it functions.

  9. I appreciate it!. I really like it when people get together and share ideas. Great website, continue the good work!. Either way, great web and I look forward to seeing it grow over time. Thank you so much.
    super smash flash 2
    bloons tower defense 5

  10. Hello!
    Thanks for posting this useful best mortgage rate canada content, Good to know about new things here, Let me share this, .

  11. I blog frequently and I really thank Murcia you for your information. The article mortgage & tax arrears has truly peaked my interest. I will book mark your blog and keep checking for new information about once per week. I opted in for your RSS feed too

  12. At this blog you will find good advices on how to write good essay and some high quality essay topics

  13. a pride for me to be able to discuss on a quality website because I just learned to make an article on
    cara menggugurkan kandungan

  14. I have read your article, it is very informative and Second home helpful for me.I admire heating pad the valuable Securities Lawyer information you offer in your articles. Thanks for posting it

  15. Great blog post! I second pig statues rates don’t understand how long it will require me to obtain through all of them!

  16. yes,...I admire what you have done here. I like financing new construction the part where you say banks construction you are doing this to give back but I would assume by all the comments that this is working for you as well.

  17. i know yes yes i yes we all visited this part of the word last year - stunning scenery and colours, and amazing bird life. The valley of Bezirgan, above Kalkan, is a real treasure to be explored and bad credit home loan refinance. As the writer says, the trekking is superb -but it wrecked my aging knees!

  18. I have read you post, Great work you really did it very well. Keep working like this and sharing informative posts like
    this one. keep it up. I'm waiting for your next post...
    real estate fredericton

  19. Great tips I have noted all in my diary I'll use your all tips as you mentioned I really like your article I was searching on this topic as I'm working on this topics 2:08 PM can see my work but yours is too good I personally appreciate you for this. Keep working like s9 trade in