Welcome. We will talk about Citrix and terminal servers. I have found some new stuff about published applications and I will show them how to connect to these published applications, but with a Citrix client you can't do that. First I have to say that this presentation will be up later on this webpage. Also the programs you have on your CD is like old, it's like very very old, like three months old or something. So there are new stuff there as well and I think the tools are there already. And about questions, if something is really not clear, okay you can ask for it, but otherwise it's better for you to come up to see me or one of my friends who have all these t-shirts. Yeah, Rick is sitting there, you can wave. Give Rick a hand now. So you don't have to take notes really. I will also make a link on this page from my part. DEF CON .org. So we will talk about what is terminal servers, terminal services, one slide or something, and then how to abuse terminal services and scanning for non-public published applications, like there are published applications that are public, that you could reach, can reach, and there are several servers out there that has published applications, but you can't just see them or connect to them. I will make a demonstration of this machine. This is a freshly installed Citrix server with some published applications. It has two network interfaces. One network interface is a master browser, it's called, Citrix Master Browser, and I can't reach it from this computer. I will show you how it can be done. Then I will show statistics from a very large scan. It's a scan for some millions of iPad addresses. I will not tell you how many servers I've found, but I will tell you about the statistics about them. What is terminal services? It's like a remote multi-user desktop. It's more or less like X. It's not that fancy for us UNIX freaks, but for Windows it's really weird. It starts an application on one server. It runs over at the server, and all changes in thegi window are going over the network, to you, the client. It's like sitting locally on a PC, but over a network. Then, Amanda says, right on target, that's yogurt! So everything, you have just a client to connect to the server, and everything is run on the server, you know? So you have to remember that. And Citrix has a feature called published application. And this means, like, well, we'll come very much into that, but it is like you can execute a program like Word or something. And you can, like, say to a server, what applications do you have that I can run? And it says, like, Word, okay, try Word, let's try it. So it's a little bit weird. So everything works fine, and it's really beautiful, this terminal services, because it's, you no longer have to, like, like, download lots of data and programs over your modern line. Because it's, the only thing that's good is, like, changes in the desktop. And it's very fast and very, very nice. So I really like it. But there are some weird things that you really have to know setting this up. There are, like, there are several people running different desktops on the Citrix server, okay? That means, like, the Citrix server created. starts up lots of desktops, and then sends the changes of each desktop to the right client, okay? If you own the Citrix server, you have access to all these desktops, of course. So that's a little bit weird. So elevation of rights, and this is done on Windows 2000, so I usually use Pipe App Admin, or Pipe App SAM. There are some different tools for elevation of rights on MT. You also, when you're starting up your application, your published application, like Notepad or something, it's just Notepad, nothing there, or is it? Well, the desktop is there, but it's just hidden. You can start it up, another thing. The problem is is breaking out from the given environment that you had. One really fun thing or weird thing about Citrix you can say these published applications are anonymous. These means you're sitting on your laptop on the internet, a Citrix server has published application that you can connect to anonymously and execute this published application. You break out from that environment and upload your cool new Elevation Rights stuff to it, elevate your rights, and you have the whole server with lots of users and bosses and so on to it, reading their mail and so on, so it's quite fun. So how do you find these published applications? I think the fastest way to find published application is to port scan for the TCP port 1494, it's like the Citrix, you always need that port. If you don't have that port, you can't connect. So it's very easy to just scan for it. But it's even easier to just search for published applications that companies are publishing for you, like Dmoves and so on. And it's weird how many servers is out there that want you to take over their network. And the use, if you find a port 1494, you can use a Citrix client to enumerate the published application. It's, you start up the Citrix network client or something, what's it called, Citrix client, and make a new connection, so it's like, I want to connect to this Citrix server, and what kind of published application does it have? And it's just like, yeah, these, and you know, go, you can start checking. Here's a network dump from normal Citrix client published application enumeration session, okay? It's like the Citrix client is asking the server, like what kind of published applications do you have? But the client do this in this way. I don't see if you see that. It occurs automatically. here, but here's the client asking the Citrix server, it's a UDP question on port 164, so the Citrix client sends a first package asking where is the master browser, and the response will be like the master browser is C1, OB, OC, OD, C1, OB, OC, OD, like twice, it's not, yeah, I'm lying a little bit, but more or less, and then, but this C1, OB, OC, OD is an IP address. So, if you just, it's from hex to digits, so then the client will ask, of course, the server, okay, I hope I'm, you are the master browser, give me your published applications, and the server will, yeah, enumerate all the published applications for you. But this is some problems. What happens if the master browser is not public? The client asks first, like, where is the master browser? And it says, like, it's on the TEM network, like our internal network, it's firewalled and everything, and the Citrix server, the Citrix client will try to connect to this TEM address. It's private. It's not a private address, but it will fail. So, you have a written small tool that just asks the Citrix server directly, give me your published applications, because otherwise, if you use the Citrix client connecting to a Citrix server and asks the server for published applications, of course, the client asks, where is the master browser? The server answers, like, it's TEM.11.12.13, so the client tries to connect to it, and of course, new connection. The little Perl script I've written, it only works in Unix, because we're using alarm functions, choosing blocking sockets. I only send, like, give me all your published applications, and it works perfectly, it's beautiful. So, it sends back one or more packages of published applications. Very cool. I'll show you later. But connecting to these published applications, okay, you have a list now, okay, here's the published applications. But how should you connect to it? Because the Citrix client is not open source, what I know, and there are really weird stuff you have to do to connect. It's not hard stuff, but it's weird stuff. Because the Citrix client, you have to spoof the answers from the Citrix server twice. This is a problem. You have to spoof the answers from the Citrix server twice. You have to spoof the answers from the Citrix server twice. There's the master browser spoof, and the application server spoof. I will show you, it's not that hard. I have written two programs that can connect directly to the published applications when the master browser is not public. Okay. I will just show you how the connection to a published application goes. First the client asks, give me, where is the master browser? And the server will tell it, yeah, it's this non-public IP address, so I have to spoof that one. And then the client will ask, like, okay, I want to connect to it. I want to connect to this published application. And the server will ask, yeah, you are welcome to do that on a non-public IP address. So the connection will fail. But if you change all the red stuff here to the public Citrix server IP address, you will get that connection. Understand? The master browser is just trying to trick you. The server is, the Citrix server has these sorts of applications. You have no need to, like, connect to this internal IP address. It's usually like they're having a firewall or something, or a NAT network. So it's, yeah. I've also written a script that will take the output from the Citrix PIS scan, that program that animate all the applications, and step through it and try to connect to all the applications. And after each connect, it will ask you how it went, like, how did it went, and will log these results. And I've checked, like, thousands of power sources. And I've published applications, so it's really a fast way to do it. It takes just a few seconds on every published application. So the Citrix PIS scan takes input, an IP address, a minus for standard input, or a file, or the keyword random, when it reads from slash dev slash u random. And then it takes the output. To get the IP addresses. And it just sends, like, get me the, yeah, the published applications. And the server will, yeah, give it to you. The proxy is a little bit weirder. You have to bear with me. The client, you start up your proxy. It can be locally on another Linux computer or something. You connect to the proxy. And you log in. And the proxy connects to the server, like, where's the master browser? The server will respond to the proxy, saying, like, it is non-public master browser IP address. But the proxy changes it to saying, like, well, the master browser is the proxy. So your client connects to the proxy next time and says, like, oh, I want to run this published application. It sends the IP address. It sends it to the server. And the server sends back, welcome to this non-public master browser address. And the proxy will change it again, like, okay, okay. Will change it again, saying, like, you are welcome to this public IP address. And then it starts the normal TCP connection. You understand that to do this, we need UDP 1604 to the Citrix server. And then it starts the normal TCP connection. And then, of course, 1494, otherwise we can't connect, okay? So we'll make a demonstration now. I will do an NMAP scan and show you the tools. Here it is. Don't sleep. So here's my Linux computer. And I set an IP address for it. Did you make a response there? No. I tried. I tried for, like, one hour. And when it didn't work, I'm really sorry. I really tried. Oh, it sucks. . What? . What do you say? . . . . . . . No, no, no. No, no. . . . It's a . It's a . . It's a . I tried to find a phone number. It's, like, not working. Okay. . . . I can tell you a little bit, I'm making a port scan, it says like port scan for 1494, and it has written like three IP addresses I wanted to check, and well, 192.168.0100 has an open port, so okay. We'll try to connect to it with our Citrix client. So, I start up my Citrix client, and I said like, oh, it's way far away, and I call it DMO, it doesn't matter, it's published applications, and here, on the server location, I enter the IP address of the server that has this open. Add, it's 192.168.0100. Add, it's 192.168.0100 for this one. So, and that's just, ah, it doesn't work. No, no, no, it shouldn't work, okay. So, I can't right now enumerate the published applications because they have two interfaces, and the one interface that I can't, I'm not connected to is the master browser. So, I can't really get the published applications right now. A lot of people, I think, like, having their Citrix servers, and like, trying to publish applications, and like, well, I can't get it with the client, so people can't see my published applications. Well, surprise for you. Now, running Citrix PSCAD, it's a small Perl script that just asks the server right away, like, what's your, what's your published applications? And there it is, and it says, the output is, like, the IP address you're connected to, and then it's the master browser IP address, and a boolean if you're, like, like, need a proxy or not. And then there comes all the published applications. And there can be hundreds of them, you know? So, we now start up our proxy instead. So, we use our proxy to connect to the, to the Citrix server. So, I now have started up the proxy, okay? It says, like, the Citrix server, we are proxy for 192.168.0.100. That's 192.168.0.100. I couldn't connect to. And I will listen on this address, because this is a remote computer that is a proxy. So, I will listen on this IP address and proxy it to the 100 address. Okay. So, I have to change server location, of course, to the proxy. And, okay. And I try to, and I try now to, to enumerate the published applications from, from, from the proxy, more or less. And the proxy tries it. But the proxy, like, saying, like, oh, wait a sec. Because the first packages, you don't know really what it is. So, the proxy says, like, oh, stop. I recognize this is an enumeration of PR, published applications. So, please try it. Try it again. Okay. We'll do that. We'll try again. Oh, there it is. So, thank you, thank you. So, we can connect to, like, Notepad or something and hope it's not passworded, anonymous. And it's more like, oh, I wanted a remote desktop window. It's more fun. So, there we'll see. And that's, like, default, default, default, finished. And I double-click here and make a prayer. Yeah. It's awesome. It's... Every time it works for me, I'm like, oh, baby. So, here's the... So, we are now connected to the main public Moser browser, public application. And there are, like, three ways of breaking out of the environment. The easiest way is, like, file, open, explore. I will do that. And, no, no, it's serious. I have done so many tests and penetration tests and so on. And... If no one of these three works, you know, it's, like, taking hours. But you have to learn these three. And there's, like, F1. Remember F1? If you have, like, a SAP, SAP L3, like, login window or something, that's F1 and start breaking out from there. And the third is, like, the task manager. People... Believe me. I, like... I checked out, like, thousands of thousands of published applications, and these three works. I will show you the statistics later. So, it's more or less, like, a file, open, and then you just take one, right-click, explore, and then magic starts happening. Like, oh, where's the desktop? Where's the desktop? Where is it? Where is it? And then you have to give it a name. You can do this. It's called a Hacking. It was hidden. It was... I recognize this. Oh, well. We'll see. could we hack it? Oh, that's it? You want me to hack it? No, it's a 100 machine. Okay, cool. Well, there's one way to do it. Think twice or something. This was with the proxy, but it takes very, very long time if you have hundreds of published applications to test. I've written another script called something. It's pas.pearl. It's just a small PEARL script that makes an ICA file. It takes the template ICA file, changes stuff in it, and then launches it. Really easy. Okay. I can show the template file. You will not see in this font, I guess. Something like this, bold or something. It's nothing really. It's like this PEARL, PEARL, PEARL changed to the published application. Name and IP, IP, IP. It's like changing to the public IP address. If you need encryption, you just add this one line here. It's in the readme files. It's not that hard. Then you have the output. The output from the scanner program. Anyway, it's the published applications. You have to rename it to pas.v. This is the output from the scanner program. I can just, if you want me, it's not that. This sucks. Something like this, I guess. It says my output here, but here it starts, like the IP address and everything. This script will parse it, like taking data from it and step through it. I can show you. Yes, from the pas.pl. It just looks up the IP address on the first application, creates an ICA file, launches the ICA file, connects to it. It's for this application called the Policy Editor for Administrators. You need a password. I don't give a fuck. The output here, I just say, okay, login required. Take the next one. It's like fax queue program. You need a password. I say login required. It's like fax cover page editor. Oh, okay. This works. Oh, what a surprise. Usually, you can just press F1 to fax cover page editor and try to connect or try to explore something from there. Usually, it tries to start up the web help and the favorites there. The open explore is much faster. I can show you the task manager. In Citrix, you press Control-F3 to get the task manager. It's just like run, explore. This is cool stuff. The Citrix client asked, the Citrix server wants access to your computer, your files, your local files on your computer. This is what it does for your client. Of course, I want full access. I will show you why because now, I can just open my computer and have all my local exploits just drag them over to the computer. Very beautiful. Thank you. Thank you. Thank you. Oh, I have to like, I'll press Control-C here. Back to the presentation somewhere. Here. Wow. So, how does it look out there? I can't really tell you how many servers I tried, but there are a lot. I will give you some statistics about it. It's not that wow thing, but it's some nice facts. You have to remember, these statistics, it's not statistical right, of course. It's more like a guideline or something. Because I'm using so short timeout values on the scans, and I met some very, very large server farms. Like, I have hundreds of applications, and on several IP addresses. So, it's the same applications in like 10 IP addresses, and that makes like, it takes over the statistics. You know? It's, you have to be, yeah, it's just more like guidelines for like, what to expect to find. Forty-two percent of the servers... Okay. That had... That had... Forty-two percent of the secret servers, you didn't need a proxy. Okay? The master browser was the public IP address tested. And, 44 percent of these servers, that you just can connect to and enumerate all the public applications, had no published applications. Fifty-eight percent of the Citrix server, you needed proxy. And, but there were less percentage that hadn't any published application. Here's the fun stuff. The servers, the Citrix servers, that you didn't need a proxy for, and had published applications, so it removes like many. The average were like 12 published applications per server. Five percent of all the published applications were, had, was anonymous and vulnerable. You understand me? So, five percent of all the published applications on these conditions, I could just connect to, get the desktop and everything, and like, do what stuff I... Wanted to do it with. I have to tell you, like, I didn't do anything. I really just tried to connect to it. I did connect to it. It let me in. I checked if I can break out from the environment. And then, if it could, I just logged off. If you needed to log in, I never tried to log in. And I never tried to hide data or something right to the hard disk and everything. So, it's... But... No, whatever. Five percent of the published applications are anonymous and vulnerable. And that's about 20 percent of the servers I tested. 20 percent of the servers was mine or more or less. And if you just there check, it's almost every time it's on an internal network. Less than one percent of the published application, you had anonymous access. But somehow you couldn't break out from the environment. It's good. It's like two percent of the servers. It's really nice. Ninety-two percent of the published application required login. And like, three percent of the published application got an expected error, like licensing problems, like, yeah, not enough licensing and so on. For the servers that... You need a proxy for, it's only two percent of the published applications. About 10 percent of the servers that are anonymous and vulnerable. One percent of the published applications have... Even less, like one percent of the servers had an anonymous application that I couldn't break out from. It could be like a DOS script or something. I tried to break with Control-C or something. And it... You just quit me out or something. And 96 percent of the published application required login. And two percent of the publication gave expected errors. I can... For... Who's... Don't need proxy. Need proxy. Yeah. So it's... It's less... So the servers that are... That are behind a firewall or something, that you... And don't have a... A proxy. That's why the public master browser seems to be less vulnerable. Yeah. People that don't have firewalls don't give care or something. So what can you do? Yeah. Of course, you need a firewall. You need... If you really want to have published applications or something, try to invest in like a VPN or solution or something. So you need to authenticate real good. And the breaking out stuff is also really hard. It's very, very, very, very, very hard because like Windows, everything is like merged with this other. Like the Explorer is like everywhere. Like open something, closing something, everything is Explorer or a web page or something. Open a document, write a URL and you can click on it and there's an Internet Explorer and everything. So I learned like strong ACLs and Regedit32 like makes it. And of course, Citrix white papers. You need white papers to connect to like checklists on white papers to how to protect you. If you don't into reading, you can like buying stuff. And there's two commercial stuff called AppSense and one other called SecureXE from SecureWave. I think the SecureXE way of doing it is really cool and they have also the website for SecureXE. They have a demonstration. They have a demonstration site running and an anonymous FTP account where you can upload your exploits to test their system. I think it's cool. So is this the end? Oh no, just scratching. It's so much more to do like if I sound like I want to connect to this very long published application name or something, what happens with the Citrix server and lots of more stuff, protocol. I don't want to call things that I really want to go into and not have the time right now. There are probably some vulnerabilities about the terminal server, but yeah, I will check it. Maybe next year. So I hope you have enjoyed it and my tools are available. If you need me, I have my business card lying here and if you have questions, you can call me also. Yeah, I live in Sweden. So if you have questions, you can call me also. It's central European time there, so don't wake me in the middle of the night. Thank you very much. Thank you very much.