1
00:00:00,840 --> 00:00:07,560
Hi, within this lecture, we're going to see how we can use this issue I.D. in order to become rude,

2
00:00:07,800 --> 00:00:12,040
and in fact, we're going to start with a very hard one, OK?

3
00:00:12,210 --> 00:00:16,680
We have seen that this user local been arrested.

4
00:00:16,680 --> 00:00:20,640
So he's over there and we have a specialist who had permission over here.

5
00:00:20,910 --> 00:00:22,620
So I'm going to just run it in.

6
00:00:22,620 --> 00:00:25,140
As you can see, we get an output over here.

7
00:00:25,140 --> 00:00:27,750
It says that calculating something, please wait.

8
00:00:28,020 --> 00:00:31,160
And we see 99 percent and it's done.

9
00:00:31,770 --> 00:00:34,000
So, as you can see, it doesn't do much.

10
00:00:34,020 --> 00:00:36,540
It calculates something and it's a done.

11
00:00:36,840 --> 00:00:38,400
So I don't know what it does.

12
00:00:38,790 --> 00:00:48,180
And again, this is one of the most actually difficult thing that you can come across in any stupid

13
00:00:48,450 --> 00:00:53,700
kind of exploit or excited kind of privileged escalation.

14
00:00:53,850 --> 00:00:56,940
But we have seen the easy ones before.

15
00:00:57,360 --> 00:00:57,830
Right.

16
00:00:58,230 --> 00:01:00,050
So I'm going to show you something.

17
00:01:00,270 --> 00:01:09,420
There is a comment called S Trace, and you can trace what a binary or a shared object does in order

18
00:01:09,420 --> 00:01:17,430
to understand the logic behind it so that you can actually take leverage off if there is any vulnerability

19
00:01:17,430 --> 00:01:20,340
in that particular file or a particular binary.

20
00:01:20,910 --> 00:01:24,520
So over here, we're tracing what a binary does.

21
00:01:24,930 --> 00:01:32,640
So that's exactly what we need because we know there is something going on in the suite as O, but we

22
00:01:32,640 --> 00:01:34,270
don't know what it does.

23
00:01:34,890 --> 00:01:42,420
So in order to understand this, I'm going to use this comment and I'm going to actually have to just

24
00:01:42,840 --> 00:01:44,640
give the full path over here.

25
00:01:44,670 --> 00:01:48,150
So this is user local been associated.

26
00:01:48,150 --> 00:01:57,360
So so make sure you type exact same command over here and it's actually traces and sees what is happening

27
00:01:57,360 --> 00:01:58,070
over there.

28
00:01:58,500 --> 00:02:04,290
And as you can see, there's a lot of writing going on over here, like printing out, going on over

29
00:02:04,290 --> 00:02:04,700
here.

30
00:02:05,130 --> 00:02:12,930
So we actually cannot see much over there and we cannot even see the beginning of this file.

31
00:02:13,590 --> 00:02:19,840
So what I'm going to do, I'm going to pipe this into more so that we can see what's going on.

32
00:02:19,860 --> 00:02:22,040
And as you can see, it's very long.

33
00:02:22,200 --> 00:02:24,570
We cannot understand anything from it.

34
00:02:24,570 --> 00:02:26,910
It just prints out something like this.

35
00:02:27,540 --> 00:02:34,890
So I'm going to clear this up and I'm going to run this one more time, but I'm going to pipe this to

36
00:02:34,890 --> 00:02:35,500
more.

37
00:02:35,880 --> 00:02:38,600
OK, so that we can see it in a better way.

38
00:02:38,970 --> 00:02:44,940
So I'm going to do something like this, but it won't work.

39
00:02:44,950 --> 00:02:51,690
As you can see, I just tried to just put the output in now, but it didn't work.

40
00:02:52,350 --> 00:02:58,740
Yeah, the I believe the way to go is to put this in more, OK, so that we can see what's going on

41
00:02:58,740 --> 00:03:05,820
in the beginning as well, because we need to find a clue in order to understand how we can leverage

42
00:03:05,820 --> 00:03:06,210
this.

43
00:03:06,630 --> 00:03:11,990
So I'm going to just pipe this into something like more.

44
00:03:12,000 --> 00:03:14,590
And if I can make the piping sign.

45
00:03:14,880 --> 00:03:15,250
Yep.

46
00:03:15,300 --> 00:03:16,170
Here we go.

47
00:03:16,450 --> 00:03:20,020
Just right more over here and hit enter and here you go.

48
00:03:20,250 --> 00:03:22,460
Now we can see the beginning.

49
00:03:23,070 --> 00:03:30,580
And as you can see, this is the beginning of this file or of this output.

50
00:03:30,960 --> 00:03:34,260
So here we have a lot of information.

51
00:03:34,560 --> 00:03:37,960
Just scan there's a little bit and see what happens.

52
00:03:38,430 --> 00:03:45,480
Let me just go down a little bit so we have a lot of jibberish things going on over here like logs and

53
00:03:45,480 --> 00:03:46,440
outputs.

54
00:03:46,650 --> 00:03:49,890
I don't know any of this right now.

55
00:03:49,890 --> 00:03:52,260
I'm just trying to make sense of something.

56
00:03:52,680 --> 00:04:03,240
And as you can see, it says that we're trying to access some files, light inside, debug, and it

57
00:04:03,240 --> 00:04:07,830
says no such file or directory over here.

58
00:04:07,830 --> 00:04:14,490
So it's trying to access some files over here, but it cannot find it for some reason.

59
00:04:15,150 --> 00:04:18,890
So, for example, preload, for example, this one.

60
00:04:19,290 --> 00:04:22,360
So we have a lot of warnings and errors over here.

61
00:04:22,380 --> 00:04:26,100
So, for example, he tries to open this as oh, that, too.

62
00:04:26,700 --> 00:04:29,060
And I believe it opens this.

63
00:04:29,070 --> 00:04:32,730
So there is nothing like an error over here.

64
00:04:32,880 --> 00:04:38,580
But for some files, we have no such file or directory errors.

65
00:04:38,920 --> 00:04:41,810
So this may be a clue why?

66
00:04:42,030 --> 00:04:49,120
Because if we can actually create a file like that exact same file, then it will be accessed.

67
00:04:49,590 --> 00:04:58,470
So if we can file, if we can find the file that will be executed like an [REMOVED] file or a file or

68
00:04:58,590 --> 00:04:59,820
just a binary.

69
00:05:00,330 --> 00:05:07,920
Then we can actually write our own exploits and make it run as root so that we can become root.

70
00:05:08,330 --> 00:05:11,690
OK, so this is a little bit hard.

71
00:05:11,700 --> 00:05:20,100
As I said before, it's not easy to find in real Pentax, but if you can find it, then you will just

72
00:05:20,100 --> 00:05:20,980
find it big.

73
00:05:21,030 --> 00:05:23,980
OK, you can get a big reward out of it.

74
00:05:24,000 --> 00:05:25,030
You can become rude.

75
00:05:25,050 --> 00:05:26,700
You can do whatever you want.

76
00:05:27,330 --> 00:05:30,540
So over here we can see how it's done.

77
00:05:30,780 --> 00:05:39,540
And again, we will find a file so that it's going to be accessed or it's going to be executed and we're

78
00:05:39,550 --> 00:05:42,740
going to try and create that file on our own.

79
00:05:43,110 --> 00:05:47,490
So we need to find no such file or directory errors over here.

80
00:05:48,040 --> 00:05:54,550
OK, if you go down with your arrow keys or by hitting enter, you will see there are a lot of them.

81
00:05:54,900 --> 00:06:01,980
So what I'm going to do, I'm going to just filter this out a little bit to understand what kind of

82
00:06:01,980 --> 00:06:04,030
files that we cannot find.

83
00:06:04,530 --> 00:06:13,200
So rather than piping this to more, I'm going to pipe this to GRAP and I'm going to search for no files.

84
00:06:13,200 --> 00:06:22,410
So in order to do that, you have to write, i.e. open and then with a Peiping sign access and then

85
00:06:22,410 --> 00:06:23,620
no such files.

86
00:06:24,060 --> 00:06:31,530
So it's either going to be open or access or no such file and we're going to see every one of those

87
00:06:31,530 --> 00:06:33,690
lines over here, OK?

88
00:06:33,810 --> 00:06:40,320
Of course, you can go for the access, but it will show you also the accessed files that files those

89
00:06:40,320 --> 00:06:41,840
files that really exist.

90
00:06:42,120 --> 00:06:45,040
So we really need no such files over here.

91
00:06:45,660 --> 00:06:47,150
So here you go.

92
00:06:47,610 --> 00:06:56,000
We found those steps like it tries to access this Etsy Usted debug, but there is no such file or directory.

93
00:06:56,790 --> 00:07:01,170
So we try to access this, but no such file or directory.

94
00:07:01,530 --> 00:07:04,980
And I believe we have to go for the open rather than access.

95
00:07:05,250 --> 00:07:10,410
So we know it's going to be opened and we know it's going to be executed.

96
00:07:10,620 --> 00:07:18,060
And in this case, for example, there's an open over here and it actually ends with asso extension.

97
00:07:18,420 --> 00:07:22,700
So I believe this is a way to go or this is our best bet.

98
00:07:23,040 --> 00:07:25,560
So I believe we can go for this.

99
00:07:25,560 --> 00:07:29,710
And if it doesn't work, we can always come back and try for the others as well.

100
00:07:30,120 --> 00:07:38,210
So we are in the home user, so most probably we can actually reach this file or folder over here.

101
00:07:38,700 --> 00:07:39,880
So let me see.

102
00:07:40,560 --> 00:07:47,170
So this is config and we don't actually have a config folder over here as well.

103
00:07:47,600 --> 00:07:56,220
OK, so since this is in the user folder, it will be actually possible for us to create that folder

104
00:07:56,400 --> 00:07:58,290
and create the file as well.

105
00:07:58,500 --> 00:08:05,880
So if it was in another user's file or folder, then it would be not possible for us to do that.

106
00:08:06,090 --> 00:08:14,190
For example, I don't know if we can actually create a file called as no no how cap or something like

107
00:08:14,190 --> 00:08:21,330
that and put it in the Etsy folder, because maybe we don't have permission for that, but we definitely

108
00:08:21,330 --> 00:08:28,900
have permission for our own user folder, which is Vivia going for the last one here as well.

109
00:08:29,410 --> 00:08:35,760
OK, so you can try the other ones here, like Etsy or like Leyb.

110
00:08:35,970 --> 00:08:39,680
But since we are user, it won't be possible for us to do that.

111
00:08:39,690 --> 00:08:40,560
Most probably.

112
00:08:40,560 --> 00:08:42,540
I don't know, maybe we can try that.

113
00:08:42,720 --> 00:08:44,720
But again, it's our best bet.

114
00:08:44,940 --> 00:08:52,530
So if I make that config, I can just see that config folder over here like this and I can go into that.

115
00:08:53,100 --> 00:08:54,220
And here you go.

116
00:08:54,450 --> 00:09:04,940
Now, if I just want to create like something like that so I can just write Nano Lipka that as Flipkart

117
00:09:04,950 --> 00:09:12,570
that see first, of course, we're going to write the C code and just compile it into a shared object

118
00:09:12,570 --> 00:09:13,770
file later on.

119
00:09:14,220 --> 00:09:17,580
And again, you don't have to know C in order to do this.

120
00:09:17,790 --> 00:09:24,220
I'm just going to show you a very simple C code and I will put it in the tray Hackney tasks as well.

121
00:09:24,840 --> 00:09:33,810
So first I'm going to include the standard IO over here and also the standard library over here like

122
00:09:33,810 --> 00:09:34,190
that.

123
00:09:34,560 --> 00:09:41,700
And after we import the libraries that we're going to using this code, we're just going to go for in

124
00:09:41,700 --> 00:09:44,740
it or just create a constructor attribute.

125
00:09:45,240 --> 00:09:50,060
OK, you can get the code from here like this, OK?

126
00:09:50,070 --> 00:09:53,600
And if you know, see, this will be very easy for you.

127
00:09:54,030 --> 00:09:58,080
And if you don't know C, maybe it will be a little bit complicated.

128
00:09:58,080 --> 00:09:59,680
But if you know any.

129
00:10:00,000 --> 00:10:02,790
Alarming language, at least you will understand the logic.

130
00:10:03,780 --> 00:10:06,470
So what does static void mean?

131
00:10:06,840 --> 00:10:14,760
So if you got any kind of Java cards or any seekers', you know, this static means it can be reached

132
00:10:14,760 --> 00:10:16,470
from anywhere in the project.

133
00:10:16,650 --> 00:10:23,940
And void means and it's actually saved in a different kind of area in the ram.

134
00:10:24,180 --> 00:10:26,720
And void means it will return nothing.

135
00:10:26,790 --> 00:10:27,220
OK.

136
00:10:27,240 --> 00:10:29,010
It will return Manado.

137
00:10:29,490 --> 00:10:32,120
And we are creating a method over here.

138
00:10:32,520 --> 00:10:40,530
And so even if you have a different name for this method in the documentation, in my task, practically,

139
00:10:40,530 --> 00:10:44,030
we can call this anything we want, like I will call it my name.

140
00:10:44,040 --> 00:10:44,820
So Atheel.

141
00:10:45,270 --> 00:10:48,270
And this will be a special attribute like this.

142
00:10:48,300 --> 00:10:56,610
OK, so a dash dash attribute and not dash actually underscore, attribute, underscore and this will

143
00:10:56,970 --> 00:10:59,010
just take in the constructor.

144
00:10:59,530 --> 00:11:02,510
OK, so this is our special method over here.

145
00:11:02,520 --> 00:11:08,430
Make sure you put on the semicolon at the end and now we're going to write what will happen when we

146
00:11:08,430 --> 00:11:12,750
execute this and then we decide of that method.

147
00:11:12,750 --> 00:11:15,480
We can just specify what to do.

148
00:11:16,020 --> 00:11:22,920
So again, I'm going to create a void over here and I'm going to call the same thing until and I will

149
00:11:22,920 --> 00:11:29,700
put curly braces right now like that and make sure you put one tab over here.

150
00:11:29,910 --> 00:11:32,730
OK, one, two, three, four spaces.

151
00:11:33,210 --> 00:11:40,680
So after four spaces, I can just run system and we're going to execute this on the system.

152
00:11:41,070 --> 00:11:42,390
So what are we going to do?

153
00:11:42,420 --> 00:11:50,070
We're going to copy the Basche and we're going to give the inside permission to bash and then we're

154
00:11:50,070 --> 00:11:55,060
going to just open the bags, postpone the shell so that we can become root.

155
00:11:55,230 --> 00:11:57,420
And again, this will be executed by root.

156
00:11:57,540 --> 00:12:01,110
So it will be good for us because.

157
00:12:01,110 --> 00:12:01,370
Why?

158
00:12:01,380 --> 00:12:09,430
Because we know sweet as O is owned by Root and we have given the special permission to access it.

159
00:12:09,960 --> 00:12:12,760
So let me write what we are going to do over here.

160
00:12:13,080 --> 00:12:16,760
So this will be in between the double quotation marks.

161
00:12:16,920 --> 00:12:24,750
So I'm going to copy the bin bash over there, OK, and I'm going to copy it under the TMP folder like

162
00:12:24,750 --> 00:12:25,190
this.

163
00:12:25,830 --> 00:12:33,510
And then you can just write and like this in and then I'm going to give the mode plus s, which is going

164
00:12:33,510 --> 00:12:37,860
to give us the Usted permission to Tempy Bash.

165
00:12:39,180 --> 00:12:45,450
And then it will be very good for us because we can just run the bin bash from the user as well.

166
00:12:45,690 --> 00:12:49,690
And you can just spawn bitmap Kaspi over here.

167
00:12:50,070 --> 00:12:55,140
So it's actually a one line code like this and it's not even a C code.

168
00:12:55,140 --> 00:12:58,080
It's just doing something with the system.

169
00:12:58,290 --> 00:13:00,360
So it will be run as a command.

170
00:13:00,510 --> 00:13:03,480
And the command that you should run is over here.

171
00:13:03,600 --> 00:13:07,590
And again, we're just going to let the root run this comment for us.

172
00:13:08,280 --> 00:13:09,710
So far, so good.

173
00:13:10,080 --> 00:13:12,150
This is the whole thing that you should run.

174
00:13:12,540 --> 00:13:19,020
OK, so this is kind of developing your own exploit, but if you don't know C again, it's fine.

175
00:13:19,020 --> 00:13:26,400
Just understand that we are making root around this thing so that it can copy the back into Tempy and

176
00:13:26,400 --> 00:13:31,170
given its UID permission to it so that we can spawn it like that.

177
00:13:31,650 --> 00:13:33,710
OK, so far so good.

178
00:13:33,900 --> 00:13:41,370
You can say this by control all and just entered out of this with control x so that we can see the leap

179
00:13:41,670 --> 00:13:45,450
that C over here under the config folder.

180
00:13:45,930 --> 00:13:46,510
OK.

181
00:13:46,620 --> 00:13:53,520
And of course we're going to have to just convert it into as oh and then we can just put it very long.

182
00:13:54,510 --> 00:14:03,000
So far we only have the leap that C over here and I'm going to use the same document that we have seen

183
00:14:03,000 --> 00:14:03,390
before.

184
00:14:03,390 --> 00:14:08,940
And you can actually reach this comment from the task, from the Try Hackney website as well.

185
00:14:09,330 --> 00:14:19,020
So I'm going to just put this under the home user dot com config that as o and I'm going to give the

186
00:14:19,020 --> 00:14:31,620
input as home user that config that C like this, OK, and it says that no such file or directory and

187
00:14:32,040 --> 00:14:32,630
lets.

188
00:14:32,660 --> 00:14:32,990
Yeah.

189
00:14:33,000 --> 00:14:40,290
I didn't put the dash over here so it should be output like this and this is our input.

190
00:14:40,740 --> 00:14:47,230
OK, so if I hit enter now it will be converted into an S o file like that.

191
00:14:47,520 --> 00:14:48,950
So if I run the SLA.

192
00:14:48,960 --> 00:14:49,730
Here you go.

193
00:14:49,770 --> 00:14:57,230
Now you have the Lipka that says, oh now we have the file that hasn't been found before.

194
00:14:57,540 --> 00:14:59,810
Now if we run the same is Eweida.

195
00:15:00,530 --> 00:15:09,200
As o thingy that we have found when we actually search for find search with the find comment now, it

196
00:15:09,200 --> 00:15:10,450
should make us root.

197
00:15:10,880 --> 00:15:17,000
Let me find that comment or let me find the path over here.

198
00:15:17,330 --> 00:15:17,900
Here you go.

199
00:15:18,200 --> 00:15:20,740
So this is the thing that we should run now.

200
00:15:20,750 --> 00:15:24,980
If I hit enter on this, it will get executed.

201
00:15:25,130 --> 00:15:30,140
And hopefully now this time it will find Dileep, Cut-out, Asso and Leaphart.

202
00:15:30,200 --> 00:15:32,290
That is all will get executed.

203
00:15:32,570 --> 00:15:33,940
And here you go.

204
00:15:33,950 --> 00:15:37,210
Now we get a Backshall over here.

205
00:15:37,850 --> 00:15:41,990
So the bag shall if on where my real root is.

206
00:15:41,990 --> 00:15:46,910
You can see we managed to escalate our privilege with a very sophisticated way.

207
00:15:47,900 --> 00:15:54,770
So you can do this, you can actually search for is your I.D. and you, if you find the binary you can

208
00:15:54,770 --> 00:16:01,100
just do the trace and see if there is any vulnerability like this and get a hold of it.

209
00:16:01,580 --> 00:16:08,170
So again, this is one of the hardest things that you can encounter on a pentathlete or CTF.

210
00:16:08,450 --> 00:16:11,840
So this is not like a very beginner challenge.

211
00:16:12,110 --> 00:16:13,340
I give you that.

212
00:16:13,490 --> 00:16:18,230
But also we we also seen the easy ones before.

213
00:16:18,410 --> 00:16:21,320
And right now, you know what that nationwide is.

214
00:16:21,470 --> 00:16:25,080
And also you need to learn about the advanced stuff here as well.

215
00:16:25,640 --> 00:16:32,990
So, again, this is a very good example of intermediate advanced kind of CTS of privilege escalations

216
00:16:32,990 --> 00:16:33,630
for you.

217
00:16:34,040 --> 00:16:39,710
So if you got confused at any point, please make sure you just watched his lecture again.

218
00:16:39,860 --> 00:16:44,810
Please make sure you scan the code that we have written in the tri.

219
00:16:44,810 --> 00:16:49,340
Hack me a website in the task in this specific related task.

220
00:16:49,670 --> 00:16:54,480
And you can try this on your own if you haven't done yet.

221
00:16:54,870 --> 00:17:00,740
OK, so you can actually find the comments or hear for your convenience as well.

222
00:17:00,920 --> 00:17:07,880
But I suggest you just take that as a note because you will need that a lot during these ETFs.

223
00:17:08,450 --> 00:17:17,960
If we exit out of this one, as you can see now, it completes the suite I saw over here and we're back

224
00:17:17,960 --> 00:17:19,790
with the user shall.

225
00:17:20,150 --> 00:17:21,100
Now it's done.

226
00:17:21,380 --> 00:17:25,730
I believe this is time to stop here and continue with the next lecture.

227
00:17:25,880 --> 00:17:30,710
But again, leveraging stupid but in different ways.
