WEBVTT

00:00.000 --> 00:01.960
Hello everybody.

00:02.340 --> 00:03.560
Thanks to be here.

00:03.560 --> 00:05.560
Thanks Defcon.

00:05.640 --> 00:14.800
So um today uh we are gonna talk about uh some way to abuse uh Google cloud services.

00:15.100 --> 00:22.980
In order to perform uh um some action in a context of uh red teaming operations.

00:25.080 --> 00:29.980
Uh first of all uh let uh let me introduce myself.

00:30.300 --> 00:33.020
My name is Valerio Alessandroni.

00:33.260 --> 00:39.000
Uh currently I am an offensive security leader at UI Italy.

00:39.000 --> 00:44.640
Uh my background is uh based on uh pentesting and red teaming.

00:46.860 --> 00:56.060
So the first topic uh is uh um research I performed uh in 2023.

00:56.060 --> 00:58.840
Which is called the Google calendar rat.

00:59.720 --> 01:14.860
Uh that was uh that is a tool uh a post exploitation tool that abuses uh of uh uh Google calendar in order to use it as a command and control infrastructure.

01:16.180 --> 01:20.920
Why I I developed this tool?

01:20.920 --> 01:31.120
Uh first of all because I wanted to um reduce uh the time to set up uh command and control infrastructure.

01:31.460 --> 01:36.020
And uh in order to to save uh to save money.

01:36.240 --> 01:44.380
Uh I wanted to perform some creative way to bypass uh uh defenses mechanism.

01:44.480 --> 01:50.160
And uh last but not least uh I wanted to have fun during the development.

01:51.720 --> 01:53.300
How it works?

01:53.300 --> 01:54.600
Pretty simple.

01:54.780 --> 01:59.560
Google calendar is the middle man inside this schema.

02:00.020 --> 02:06.040
Um you have uh uh an agent that you deploy on your target machine.

02:06.060 --> 02:11.340
Uh the the original uh POC has been developed in uh in Python.

02:11.400 --> 02:21.800
Uh with a polling mechanism um the agent uh and the attacker can communicate uh with the Google calendar in the middle.

02:22.100 --> 02:29.580
And then you can establish uh connections and commands and receive the the output of those commands.

02:31.420 --> 02:35.640
Uh I think it's stuck.

02:35.640 --> 02:36.760
Okay.

02:37.280 --> 02:40.760
So I released the tool in 2023.

02:40.860 --> 02:51.960
Uh a few months later uh the Google cyber security action team uh mentioned the tool uh uh within the threat horizon report.

02:52.380 --> 03:01.220
Uh um but the most important uh event that happened was about uh few months ago.

03:01.220 --> 03:03.680
Maybe on April of this year.

03:03.680 --> 03:12.680
Uh while um APD41 uh used uh a similar technique based on uh Google calendar.

03:12.680 --> 03:15.120
But we will talk about it later.

03:18.430 --> 03:21.810
So uh how it works?

03:21.810 --> 03:22.810
Pretty easy.

03:22.810 --> 03:31.810
Uh when you create uh an event on uh Google calendar you have uh two two fields that you can uh put your data on.

03:31.810 --> 03:34.250
The title field and the description field.

03:35.090 --> 03:41.750
Uh the title accept up to uh 1,024 characters.

03:41.750 --> 03:45.190
And the description more than 8,000 characters.

03:45.190 --> 03:58.770
So I ask myself why can't I use that in order to put data and create a communication channel uh exploiting Google uh Google calendar.

03:58.770 --> 04:18.530
So uh I developed the the tool uh and the um the requirements uh to use it are the creation of a service account which is basically um uh an account that can take uh the control of your Gmail account.

04:18.530 --> 04:22.750
Uh so you can use it inside uh a software for automation.

04:22.810 --> 04:27.130
And you you have to enable the the API.

04:27.130 --> 04:29.790
In this case the the Google calendar API.

04:30.410 --> 04:42.090
Once you create uh a Google calendar um and you share with your accounts, you are ready for establish the communication.

04:43.670 --> 04:49.230
So this is uh um the the POC of the tool.

04:49.230 --> 04:53.650
On the uh left side there is the target machine.

04:53.650 --> 04:57.150
On the uh right side uh the attacker machine.

04:57.150 --> 04:59.370
So we are running the tool.

05:00.310 --> 05:05.030
And uh it uh communicates directly with Google calendar.

05:05.030 --> 05:17.170
For this example we will use the Google uh calendar web application interface uh in order to in order to send and receive the commands.

05:17.330 --> 05:34.790
Uh we can see in the description field of the event uh on the left side uh uh the input command and right after with a pipe as a separator, the output that is uh base 64 encoded.

05:35.810 --> 05:50.870
So you can see that uh it's pretty easy to use it and uh no direct connection between uh the attacker and the target uh uh is established.

05:53.810 --> 05:56.870
Some security consideration.

05:58.070 --> 06:00.590
You don't need an infrastructure.

06:00.590 --> 06:07.170
So you can set up uh uh your environment uh in uh in few minutes.

06:07.170 --> 06:08.850
You don't need to buy domain name.

06:08.850 --> 06:16.170
You don't need to buy VPS uh and that's because you exploit the Google trust.

06:16.710 --> 06:22.330
Uh as accounts uh Google is a single point of failure.

06:22.330 --> 06:31.330
Because uh if an organization doesn't allow the traffic to Google uh it will it will it won't work.

06:34.890 --> 06:49.490
Few months ago uh Google analyzed uh some APT 41 actions uh and they discovered that uh they were spreading a malware called tough progress.

06:51.010 --> 07:02.650
Um I thank their effort for this uh research uh but I think they missed uh um a point.

07:02.650 --> 07:10.030
When I released the GCR, the Google Calendar Router, I put an IOC inside the code.

07:10.110 --> 07:15.810
Which was uh um hard coded data of for the event creation.

07:15.810 --> 07:19.550
Which was set up on May 30, 2023.

07:19.770 --> 07:25.630
And on the left image you can see the GSR, GCR sorry.

07:25.670 --> 07:28.750
Uh events with that that date.

07:28.750 --> 07:33.870
And on the right image the Google report.

07:33.870 --> 07:44.070
So APT use the same the same data that's an in an indicator that uh tough progress uh is based on uh a Google Calendar Router.

07:46.340 --> 07:54.180
Of course uh uh that is not the only tool that abuses uh Google Cloud.

07:54.180 --> 07:56.300
There are multiple tool.

07:56.320 --> 07:58.800
One of them uh is called GSR.

07:58.800 --> 08:09.260
Is uh a tool I developed uh um some few months uh later the later I released the Google Calendar Router.

08:09.260 --> 08:14.320
But all those tools has something in common.

08:14.720 --> 08:21.320
They are limited to a synchronous uh request response uh communication model.

08:21.320 --> 08:28.220
And uh you are not able to vehiculate to tunnel your own uh protocol.

08:29.360 --> 08:50.380
That's why today I'm gonna release a new tool uh which uh allow you to tunnel uh your your uh favorite protocol uh within a SOCKS5 proxy server uh by using uh Google uh Google Cloud.

08:50.680 --> 08:54.500
So the tool is called the GSSOCKS.

08:54.500 --> 08:57.700
Is a post uh exploitation tool.

08:57.700 --> 09:02.440
Uh this time I decided to use uh Go as a language.

09:02.620 --> 09:17.060
And uh and uh set up a uh a uh a uh a uh a uh a uh a SOCKS5 proxy in order to vehiculate to tunnel uh every protocol by using proxy chains for example.

09:20.980 --> 09:24.680
The mechanism is similar to Google Calendar Router.

09:24.680 --> 09:28.100
Uh we have 2 2 parts.

09:28.100 --> 09:29.240
2 entities.

09:29.240 --> 09:32.680
The GSSOCKS client and the server.

09:32.680 --> 09:43.940
The client stays on the attacker machine and the server uh is the is the agent that must be deployed on the on the target machines.

09:44.160 --> 09:54.760
Uh this time I decided to use Google Sheets uh because it's the most similar uh service uh that functions as a database.

09:54.840 --> 10:01.980
Um the client uh uh open a listener on port uh on a local port.

10:01.980 --> 10:04.360
This case a 9191.

10:04.380 --> 10:11.820
You can set up uh a proxy chains in order to send uh all the traffic through this port.

10:11.880 --> 10:15.260
Uh traffic go over Google Sheets.

10:15.260 --> 10:22.920
On the other side the server the agent uh read those information and send them to a proxy server.

10:22.920 --> 10:31.460
And then you are able to reach uh every service uh that is uh reachable from the from the target machine.

10:33.020 --> 10:38.660
So uh this is the the the Sheets model.

10:38.660 --> 10:43.140
Uh we have uh some uh some columns.

10:43.140 --> 10:44.400
The socket ID.

10:44.400 --> 10:49.140
Uh a label to identify the client or the server.

10:49.140 --> 10:52.920
Uh a time stamp and um and the payload.

10:56.270 --> 10:58.230
So uh there are some limitations.

10:58.770 --> 11:14.230
Uh for uh for the payload encoding uh I had to use base 64 which uh increase uh the overhead uh about of uh 33 percent.

11:14.590 --> 11:23.670
And uh Google Sheets has uh a limit for uh a single cell of 5,000 characters.

11:23.890 --> 11:28.490
So um the the first test of which is uh to uh to uh to uh to execute a command.

11:28.490 --> 11:31.350
So I was using uh some common tools.

11:31.350 --> 11:32.450
PSX sec.

11:32.450 --> 11:34.870
PSX sec and secret dumps.

11:34.870 --> 11:39.410
So common pen testing tools to uh for Windows exploitation.

11:39.510 --> 11:47.610
And uh before the optimization uh PSX sec required about 20 minutes to execute a command.

11:47.610 --> 11:55.610
While secret dump required uh 15 minutes to execute uh to to extract uh the the information.

11:55.730 --> 12:10.590
So I opted my uh the the software uh splitting uh the the payload the the byte stream uh considering the limitation of 5,000 characters.

12:10.590 --> 12:19.470
But the main improvement is uh uh the implementation of um uh rotational account system.

12:19.470 --> 12:26.830
So after those uh corrections uh PSX sec required 2 minutes.

12:27.870 --> 12:30.470
And secret dump uh just 1 minute.

12:30.470 --> 12:32.430
So it's pretty usable.

12:34.740 --> 12:40.320
Uh this is a demo of uh the execution of secret dump.

12:41.160 --> 12:47.000
So um the agent is uh already deployed on a target machine.

12:47.040 --> 12:49.520
Uh we won't see that uh here.

12:49.760 --> 12:58.720
Uh we set up uh on the uh um right side top uh top right uh uh our client.

12:58.720 --> 13:05.860
And we use the other virtual machine on the left uh uh running uh proxy chains uh and secret dump.

13:05.860 --> 13:07.940
Secret dump over proxy chains.

13:07.940 --> 13:14.780
And on the bottom right uh we can see the information transmitted through Google sheets.

13:21.400 --> 13:27.380
So in a few seconds uh it will be completely executed and we'll read all the secrets.

13:35.860 --> 13:50.520
For this uh example I used uh about uh 3 and 3 accounts on the client and 4 accounts uh on the on the server.

13:50.520 --> 13:53.840
Due to the API quota limits.

13:54.380 --> 13:56.220
So it works.

13:56.220 --> 14:04.960
Everything has been executed and no direct connection has been performed for this exploitation.

14:08.710 --> 14:17.290
If uh if you want to see the uh you try to analyze uh traffic of uh the agent of the server.

14:17.290 --> 14:25.490
You'll see that only uh connection to Google infrastructure uh is established.

14:25.490 --> 14:37.810
So it means that uh even uh uh we even um traffic inspection uh won't work against that.

14:37.950 --> 14:55.470
Uh for the future I'm gonna analyze further um what can be done in terms of uh analysis but I will release on the uh repository page repository GitHub soon.

14:58.520 --> 15:00.400
Google mitigation.

15:00.400 --> 15:08.280
During testing uh I I encountered this message.

15:08.280 --> 15:13.860
So I was testing and uh some of my account uh has been disabled.

15:13.860 --> 15:17.500
So I say oh yeah uh Google catched me.

15:17.600 --> 15:20.240
Uh but there is a button right there.

15:20.240 --> 15:21.300
Start appeal.

15:21.300 --> 15:35.980
And I I started an appeal and uh I was surprised that in less than 1 hour uh my account were fully restored so I continued my test and they have not been blocked again.

15:38.260 --> 15:39.960
Thank you so much.

15:40.280 --> 15:44.000
If you have uh any questions I'll be right there.

15:44.600 --> 15:52.680
And uh for my friends, Italian friends uh for Sanaboly.

15:53.280 --> 15:54.900
Thank you so much.

