1 00:00:00,000 --> 00:00:01,960 Hello everybody. 2 00:00:02,340 --> 00:00:03,560 Thanks to be here. 3 00:00:03,560 --> 00:00:05,560 Thanks Defcon. 4 00:00:05,640 --> 00:00:14,800 So um today uh we are gonna talk about uh some way to abuse uh Google cloud services. 5 00:00:15,100 --> 00:00:22,980 In order to perform uh um some action in a context of uh red teaming operations. 6 00:00:25,080 --> 00:00:29,980 Uh first of all uh let uh let me introduce myself. 7 00:00:30,300 --> 00:00:33,020 My name is Valerio Alessandroni. 8 00:00:33,260 --> 00:00:39,000 Uh currently I am an offensive security leader at UI Italy. 9 00:00:39,000 --> 00:00:44,640 Uh my background is uh based on uh pentesting and red teaming. 10 00:00:46,860 --> 00:00:56,060 So the first topic uh is uh um research I performed uh in 2023. 11 00:00:56,060 --> 00:00:58,840 Which is called the Google calendar rat. 12 00:00:59,720 --> 00: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. 13 00:01:16,180 --> 00:01:20,920 Why I I developed this tool? 14 00:01:20,920 --> 00:01:31,120 Uh first of all because I wanted to um reduce uh the time to set up uh command and control infrastructure. 15 00:01:31,460 --> 00:01:36,020 And uh in order to to save uh to save money. 16 00:01:36,240 --> 00:01:44,380 Uh I wanted to perform some creative way to bypass uh uh defenses mechanism. 17 00:01:44,480 --> 00:01:50,160 And uh last but not least uh I wanted to have fun during the development. 18 00:01:51,720 --> 00:01:53,300 How it works? 19 00:01:53,300 --> 00:01:54,600 Pretty simple. 20 00:01:54,780 --> 00:01:59,560 Google calendar is the middle man inside this schema. 21 00:02:00,020 --> 00:02:06,040 Um you have uh uh an agent that you deploy on your target machine. 22 00:02:06,060 --> 00:02:11,340 Uh the the original uh POC has been developed in uh in Python. 23 00:02:11,400 --> 00: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. 24 00:02:22,100 --> 00:02:29,580 And then you can establish uh connections and commands and receive the the output of those commands. 25 00:02:31,420 --> 00:02:35,640 Uh I think it's stuck. 26 00:02:35,640 --> 00:02:36,760 Okay. 27 00:02:37,280 --> 00:02:40,760 So I released the tool in 2023. 28 00:02:40,860 --> 00: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. 29 00:02:52,380 --> 00:03:01,220 Uh um but the most important uh event that happened was about uh few months ago. 30 00:03:01,220 --> 00:03:03,680 Maybe on April of this year. 31 00:03:03,680 --> 00:03:12,680 Uh while um APD41 uh used uh a similar technique based on uh Google calendar. 32 00:03:12,680 --> 00:03:15,120 But we will talk about it later. 33 00:03:18,430 --> 00:03:21,810 So uh how it works? 34 00:03:21,810 --> 00:03:22,810 Pretty easy. 35 00:03:22,810 --> 00: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. 36 00:03:31,810 --> 00:03:34,250 The title field and the description field. 37 00:03:35,090 --> 00:03:41,750 Uh the title accept up to uh 1,024 characters. 38 00:03:41,750 --> 00:03:45,190 And the description more than 8,000 characters. 39 00:03:45,190 --> 00: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. 40 00:03:58,770 --> 00: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. 41 00:04:18,530 --> 00:04:22,750 Uh so you can use it inside uh a software for automation. 42 00:04:22,810 --> 00:04:27,130 And you you have to enable the the API. 43 00:04:27,130 --> 00:04:29,790 In this case the the Google calendar API. 44 00:04:30,410 --> 00:04:42,090 Once you create uh a Google calendar um and you share with your accounts, you are ready for establish the communication. 45 00:04:43,670 --> 00:04:49,230 So this is uh um the the POC of the tool. 46 00:04:49,230 --> 00:04:53,650 On the uh left side there is the target machine. 47 00:04:53,650 --> 00:04:57,150 On the uh right side uh the attacker machine. 48 00:04:57,150 --> 00:04:59,370 So we are running the tool. 49 00:05:00,310 --> 00:05:05,030 And uh it uh communicates directly with Google calendar. 50 00:05:05,030 --> 00: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. 51 00:05:17,330 --> 00: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. 52 00:05:35,810 --> 00: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. 53 00:05:53,810 --> 00:05:56,870 Some security consideration. 54 00:05:58,070 --> 00:06:00,590 You don't need an infrastructure. 55 00:06:00,590 --> 00:06:07,170 So you can set up uh uh your environment uh in uh in few minutes. 56 00:06:07,170 --> 00:06:08,850 You don't need to buy domain name. 57 00:06:08,850 --> 00:06:16,170 You don't need to buy VPS uh and that's because you exploit the Google trust. 58 00:06:16,710 --> 00:06:22,330 Uh as accounts uh Google is a single point of failure. 59 00:06:22,330 --> 00:06:31,330 Because uh if an organization doesn't allow the traffic to Google uh it will it will it won't work. 60 00:06:34,890 --> 00: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. 61 00:06:51,010 --> 00:07:02,650 Um I thank their effort for this uh research uh but I think they missed uh um a point. 62 00:07:02,650 --> 00:07:10,030 When I released the GCR, the Google Calendar Router, I put an IOC inside the code. 63 00:07:10,110 --> 00:07:15,810 Which was uh um hard coded data of for the event creation. 64 00:07:15,810 --> 00:07:19,550 Which was set up on May 30, 2023. 65 00:07:19,770 --> 00:07:25,630 And on the left image you can see the GSR, GCR sorry. 66 00:07:25,670 --> 00:07:28,750 Uh events with that that date. 67 00:07:28,750 --> 00:07:33,870 And on the right image the Google report. 68 00:07:33,870 --> 00: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. 69 00:07:46,340 --> 00:07:54,180 Of course uh uh that is not the only tool that abuses uh Google Cloud. 70 00:07:54,180 --> 00:07:56,300 There are multiple tool. 71 00:07:56,320 --> 00:07:58,800 One of them uh is called GSR. 72 00:07:58,800 --> 00:08:09,260 Is uh a tool I developed uh um some few months uh later the later I released the Google Calendar Router. 73 00:08:09,260 --> 00:08:14,320 But all those tools has something in common. 74 00:08:14,720 --> 00:08:21,320 They are limited to a synchronous uh request response uh communication model. 75 00:08:21,320 --> 00:08:28,220 And uh you are not able to vehiculate to tunnel your own uh protocol. 76 00:08:29,360 --> 00: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. 77 00:08:50,680 --> 00:08:54,500 So the tool is called the GSSOCKS. 78 00:08:54,500 --> 00:08:57,700 Is a post uh exploitation tool. 79 00:08:57,700 --> 00:09:02,440 Uh this time I decided to use uh Go as a language. 80 00:09:02,620 --> 00: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. 81 00:09:20,980 --> 00:09:24,680 The mechanism is similar to Google Calendar Router. 82 00:09:24,680 --> 00:09:28,100 Uh we have 2 2 parts. 83 00:09:28,100 --> 00:09:29,240 2 entities. 84 00:09:29,240 --> 00:09:32,680 The GSSOCKS client and the server. 85 00:09:32,680 --> 00: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. 86 00:09:44,160 --> 00: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. 87 00:09:54,840 --> 00:10:01,980 Um the client uh uh open a listener on port uh on a local port. 88 00:10:01,980 --> 00:10:04,360 This case a 9191. 89 00:10:04,380 --> 00:10:11,820 You can set up uh a proxy chains in order to send uh all the traffic through this port. 90 00:10:11,880 --> 00:10:15,260 Uh traffic go over Google Sheets. 91 00:10:15,260 --> 00:10:22,920 On the other side the server the agent uh read those information and send them to a proxy server. 92 00:10:22,920 --> 00:10:31,460 And then you are able to reach uh every service uh that is uh reachable from the from the target machine. 93 00:10:33,020 --> 00:10:38,660 So uh this is the the the Sheets model. 94 00:10:38,660 --> 00:10:43,140 Uh we have uh some uh some columns. 95 00:10:43,140 --> 00:10:44,400 The socket ID. 96 00:10:44,400 --> 00:10:49,140 Uh a label to identify the client or the server. 97 00:10:49,140 --> 00:10:52,920 Uh a time stamp and um and the payload. 98 00:10:56,270 --> 00:10:58,230 So uh there are some limitations. 99 00:10:58,770 --> 00: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. 100 00:11:14,590 --> 00:11:23,670 And uh Google Sheets has uh a limit for uh a single cell of 5,000 characters. 101 00:11:23,890 --> 00:11:28,490 So um the the first test of which is uh to uh to uh to uh to execute a command. 102 00:11:28,490 --> 00:11:31,350 So I was using uh some common tools. 103 00:11:31,350 --> 00:11:32,450 PSX sec. 104 00:11:32,450 --> 00:11:34,870 PSX sec and secret dumps. 105 00:11:34,870 --> 00:11:39,410 So common pen testing tools to uh for Windows exploitation. 106 00:11:39,510 --> 00:11:47,610 And uh before the optimization uh PSX sec required about 20 minutes to execute a command. 107 00:11:47,610 --> 00:11:55,610 While secret dump required uh 15 minutes to execute uh to to extract uh the the information. 108 00:11:55,730 --> 00: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. 109 00:12:10,590 --> 00:12:19,470 But the main improvement is uh uh the implementation of um uh rotational account system. 110 00:12:19,470 --> 00:12:26,830 So after those uh corrections uh PSX sec required 2 minutes. 111 00:12:27,870 --> 00:12:30,470 And secret dump uh just 1 minute. 112 00:12:30,470 --> 00:12:32,430 So it's pretty usable. 113 00:12:34,740 --> 00:12:40,320 Uh this is a demo of uh the execution of secret dump. 114 00:12:41,160 --> 00:12:47,000 So um the agent is uh already deployed on a target machine. 115 00:12:47,040 --> 00:12:49,520 Uh we won't see that uh here. 116 00:12:49,760 --> 00:12:58,720 Uh we set up uh on the uh um right side top uh top right uh uh our client. 117 00:12:58,720 --> 00:13:05,860 And we use the other virtual machine on the left uh uh running uh proxy chains uh and secret dump. 118 00:13:05,860 --> 00:13:07,940 Secret dump over proxy chains. 119 00:13:07,940 --> 00:13:14,780 And on the bottom right uh we can see the information transmitted through Google sheets. 120 00:13:21,400 --> 00:13:27,380 So in a few seconds uh it will be completely executed and we'll read all the secrets. 121 00:13:35,860 --> 00: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. 122 00:13:50,520 --> 00:13:53,840 Due to the API quota limits. 123 00:13:54,380 --> 00:13:56,220 So it works. 124 00:13:56,220 --> 00:14:04,960 Everything has been executed and no direct connection has been performed for this exploitation. 125 00:14:08,710 --> 00: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. 126 00:14:17,290 --> 00:14:25,490 You'll see that only uh connection to Google infrastructure uh is established. 127 00:14:25,490 --> 00:14:37,810 So it means that uh even uh uh we even um traffic inspection uh won't work against that. 128 00:14:37,950 --> 00: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. 129 00:14:58,520 --> 00:15:00,400 Google mitigation. 130 00:15:00,400 --> 00:15:08,280 During testing uh I I encountered this message. 131 00:15:08,280 --> 00:15:13,860 So I was testing and uh some of my account uh has been disabled. 132 00:15:13,860 --> 00:15:17,500 So I say oh yeah uh Google catched me. 133 00:15:17,600 --> 00:15:20,240 Uh but there is a button right there. 134 00:15:20,240 --> 00:15:21,300 Start appeal. 135 00:15:21,300 --> 00: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. 136 00:15:38,260 --> 00:15:39,960 Thank you so much. 137 00:15:40,280 --> 00:15:44,000 If you have uh any questions I'll be right there. 138 00:15:44,600 --> 00:15:52,680 And uh for my friends, Italian friends uh for Sanaboly. 139 00:15:53,280 --> 00:15:54,900 Thank you so much.