 Hey everybody, this is Brian, and welcome to the 101st Cute Tutorial with C++ and GUI programming. Um, I'm going to do something a little bit different. First off, I want to make special note that this is not Cute 101, okay, this is not the beginning. This is the 101st tutorial. So if you're just now tuning in, you're missing 100 tutorials that I put out on my YouTube channel, which is youtube.com slash user slash void realms. You can also go to my website void realms.com and just click on tutorials. Go over to Cute, and you have a nice little search function, and you can go into each one and watch the video and download the source code. Um, what we're going to cover today is something I actually wanted to avoid, but I had an interesting email from a woman who goes by the name of Christopher. You're probably saying, what, Christopher? Yes. She said she's not going to use her real name because she fears persecution. The country she's in, which I'm not even going to name it, has very limited internet access, and they use what's called Tor to get out of their very sheltered internet, out to the actual internet to get things that their government considers illegal, but they are just basic human rights. Like searching Google in her country is illegal. Can you believe that? I use Google every day at work, but in her country it's illegal because her country, their government, does not want their citizens knowing certain things, like freedom, or cheeseburgers, or whatever. Anyways, this is not going to be about politics. This is going to be about connecting cute to Tor. If you don't know what Tor is, hop on over to torproject.org. Tor stands for the onion router, and you can read all about it. Basically, Tor is a product, I shouldn't say product, is a birth child of a US Navy intelligence. Very short, what it is, it's a very sophisticated proxy. It hides your IP address. It has what's called in nodes and exit nodes, so you go into Tor, the onion router, with your IP address. You come out of Tor with a different IP address. Think about that for a minute. How do you track somebody across the internet? IP addresses. Let's say you have an IP address of 1010.001. I know that's not your actual IP address, so I'll use Cisco people that they're screaming at your monitor right now. When you use Tor, it would come out as 128.6.3.5. Totally different IP. It has nothing even remotely to do with your connection. But that's how it works. Let's just take a quick peek at Tor here. What we're going to do is just go to Tor, go download, and then I want you to download the Tor browser bundle for Windows. Don't worry, this won't install anything on your system. Actually, all it does is extract it to a directory. Let me see if I can pull that directory up here. There we go. And this is what you'll see. And when you start the Tor browser, it will start a copy of Firefox, plus it'll start what's called Vidalia, this thing, which is actually at the Tor. And you see it says Tor is not running. Well, I did that on purpose. It will say running, and you'll see it down in your control panel. But in order to do this tutorial, you're going to need to go into advanced. And then we're going to set the authentication to none. I just want to make sure it's set to none because I don't want to get bombarded with a million, hey, I can't connect to my own Tor that's sitting on my own desktop. But to set it to none, save yourself a lot of headache. Now, for production level code, obviously you need a username password, and you can set that, you know, through cookie or password, et cetera, et cetera. But for the tutorials, you're going to set it to none. Take note of the IP address. This is your local loopback, 127.001. And the port, in my case, it's 90.51. When you're done, click OK. And then click Start Tor. And what this does is it goes out and it connects to the onion router. And this is a massive network. I mean, massive is an understatement. But what this does is, see, we're connected, is it connects all over the world. So let's just view network and see if I can kind of squeeze us in here. Here are some of the people I'm connecting to. I mean, it's just an insane list. And what this does, it doesn't just connect to this guy and then go straight to Google or wherever I'm going. It bounces from him to him to him to him. I mean, it's random every single time. And a lot of these nodes don't even have logging enabled. Law enforcement or a government, good luck trying to find that packet, especially seeing how it's different every single time. Now, quick note, some French researchers have found many vulnerabilities in Tor. But if you use Tor correctly, it's actually very, very safe. So what does this have to do with us? Well, Christopher, whoever she may be, wanted to know how to write a cute application that takes Tor and uses it. Very, very good question. So what I want you to do, and I took a screenshot of it, blocked out my IP address because I don't want anybody trying to do any little nasties to me. But go out to any website. I used whatsmyip.org. Take note of the IP address. Mine ends in 229.154. And we're going to prove that this is actually working here. Let me just kind of minimize that. Bring Qt back up here. And we are going to make a drum roll. Drum roll. There it is. Qt console application. And let's just call this Tor test. Put this in the usual location. Now, you should note that if you close the browser window that you used to kick off Tor, it will close Tor itself. So leave that browser window open in the background. Let me kind of show you what I'm talking about here. When you double click start Tor browser, it will pop open an instance of Firefox. And it will pop open the Vidalia control panel, which will be down by your clock in your control panels, or in your status bar, sorry. But leave the browser open in the background because when you close it, it will close your connection to Tor. So as long as you see this on your screen and it's this connected to Tor network, you are good. Alright, now. First thing we're going to do is make a class here. So we're going to go add new class. And we're just going to call it tester. Q object. Alright. Now let's add in some header goodness here. And I'm just going to say, oopsie. Include. We want Q network. I didn't include our project file. It's back up here. I got so excited about this. I forgot one simple step here. We're going to include network in our project. That way we have all those network headers at our disposal. Yeah, much better list. Q network access manager. That's actually part of Q Webkit. We'll get into that in other tutorials, but I just want to show you the bare bones basics of this. And of course we need Q network reply. I did a quick poll in the last tutorial about whether I should have the code already written or whether you guys like watching me type. The vast majority of you like watching me screw up my typing. We need Q network response. Oops, we already got response work. We want request. There we go. Sorry, I was thinking in .NET for a minute there. Forgive me. And we want of course Q debug, so we can see what is going on here. And I'm going to include, I keep doing define for some reason, Q network proxy. Now you notice how I kind of bumped Q network proxy down? Because you can get a working application with just these. The Q network access manager will go out and make HTTP requests and get the responses and do all its magic. But you use a Q network proxy to go through a proxy server or a proxy service like you guessed it, Tor. Now let's just kind of add a few other things in here. We want to add two slots. Get URL. And let's say apply. Finished. Hope if I get spell finished right. Q network reply. Reply. And if you're wondering where I got that from, how I knew it had that function prototype. So we go into help, click Q, or search for a Q network proxy. Read the info. And there is a very good thing there. But you can also go into here and go Q network access manager. And this is where you should get really familiar with is the Qt help system. And you can get a very bare bones example right there. And that's exactly what we're going to be doing. All right. So now that we got these in place, let's just add the definitions here. I know, I know, I can already hear. I can already hear accidentally pointing, screaming at his monitor, hey, close the sidebar. There we go. So the first thing we're going to do is push out this get URL. And this is where all the magic is going to happen. And the way Q network access manager works is it's signal and slot-oriented. So it'll do its actions and then emit the reply finished. And we catch that here. So let's just drill through here without further ado. We'll say Q debug, connecting. And then we're going to fire off our Q network access manager here. This of course is a pointer. We'll call manager. Yeah. Access manager. This is the parent that waits automatically destroyed. And then we need to connect up our signals and slots here. So we'll say connect. And we are going to get the finished. And we're going to connect it with this slot. Reply finished. Whoops. I bet you that'll cause a compile error later. And then we're just going to simply say manager get. And this is going to perform an HTTP get. So in other words it's going to go out and request a webpage. So we want a Q network request. And we want that with a Q URL. And here's where we give it the address. I'm just going to say google.com just for this part of the demonstration here. And then we're going to down here. This is the reply finished. This is after the network manager does its get. It's going to download it into a buffer. And then it's going to emit the signal and call our slot the reply finished. So we're just going to simply say Q to bug. Let's call this response. And now what we want to do is we want to read the reply. So we're going to say if reply and whereas it is open. Then we're just going to simply read it. And because this is going to be coming out of console window we're only going to read a little bit of it. We're just going to say read. And let's just say the first 5000 bytes. That should be plenty. And then we're going to say reply.close. Very simple example once again. This isn't even the heart of the tutorial. This is just us setting up Q network access manager. Let's run this. Give it a good build. And whoopsie nothing happened because we didn't set up our stuff. Go back into main here. Somebody once asked me what's the difference between the quotes and the brackets. Well the quotes will look in the current directory. And the brackets will just start going through all the system directories looking for these things. Alright so let's say tester. C test. C test. And we want to call geterl. Alright now we build this. And it went a little fast but it says connecting response. And then here is all the HTTP or I should say HTML goodness that we got from Google. You see it's just one big blob of data. Alright now. I'm going to close that. And you know I didn't shut down gracefully. For this tutorial I'm not going to really worry about that. I'm going to let you figure that part out. Because it's really not hard you just do the reply close. And what we're going to focus on is turning this into, you guessed it, using Tor. So go back to your IP page, whatever you chose. Let's see here. Remember I chose what'smyip.org. But you can use pretty much anything that's just going to give you your IP address. Admittedly I use this one just because the IP is in very big bold letters. Let's see, bring it up again. It's in very big bold letters and it's within the first 5,000 bytes. There's not a lot of advertisements in there. Now what we're going to do is we're going to set up our connection to the proxy. So we're going to say queue network. I'm sorry my cat was wanting my attention here. Queue network proxy and we're just going to call this proxy. And in case you're wondering, save yourself some typing, you can actually just go right out to help here. Queue network proxy, scroll down and pretty much just take this whole chunk right here. Copy that, paste it in. And then we're going to walk through this line by line. Alright now we're taking our queue network proxy object and we want to set this to default project. Notice how it says socks5proxy. I know you're screaming at your monitor right now, hey, Tor is socks5, why are you setting it to default? Well, it's because of this line at the bottom, set application proxy. What that says is every queue socket in your application is going to go through this proxy. Period. Now you can set it on a per socket basis, but we're going to say everyone that you open up in your application is going to go through Tor. And then you see the set hostname. Well, we're just going to, let's pull up Vidalia here. Remember we go into advanced. We're going to use the local loopback because it's installed locally on port 9051. So very simple. We'll set our hostname, 9051. Now you see how I have username and password commented out? That's because we are not using a username and password in Tor. For a production level, you would want a username and password that way. You know, your buddy sitting in the coffee shop isn't going to bridge through your computer onto the Tor network. All right. And that's pretty much all there is to it. So if we've done everything correctly and this thing doesn't explode when I try to build it, it will go out, connect a Tor on your local computer through port, whatever you have. And then it'll use that as a proxy. Go through the onion router. Remember this, let me actually show you here, this big list and yours is going to be different. This huge list is going to route around the entire globe and then it'll return the settings. So let's give it a shot and see what happens. And ta-da! Connecting response. Now we got to kind of dig through this HTTP stuff here. And I would almost advise kind of going through and dumping this because it's going to be a QBiter, right? Just dumping it to a file. But anyways, it says your IP address is, let me just mark this. 76124134254. Well, let's bring up my actual IP address. 229154. Not the same, is it? This is somebody else's IP address. This is actually the IP address of the Tor exit note. Meaning if somebody, your teacher, your boss, your spouse, your government, were trying to track that traffic, they'll see that IP address. Not yours. Now, you have to make sure that every single packet you send is going to go out through the Tor network. That's why we have it as set application proxy. Because we don't want to take the chance that you, you know, finger something or miss one of the sockets. So we're going to say every single one goes through Tor. Anyways, this is Brian. I want to thank you for watching. Wow, I honestly, I cannot believe we've got 101 videos. That's just crazy. And I've got so much user feedback. I don't even know what to do with it at this point. I'll be brutally honest with you. I'm still slugging away through messages. So if you've messaged me, I'm not ignoring you. I apologize. I'll try to get to you. But at this point, it might be four or five years. I'm just kidding. I will try to get through them faster. Anyways, thanks for watching. Oh, and I wanted to say, if you guys got any ideas for the advanced tutorials, because now that we're over 100, I'm still going to have some newbie stuff, but I want to really focus on the more advanced stuff. I want to do things like WebKit. You know, see now that I'm on the spot making the video, I can't even think of the queue. Oh gosh, what is it? Scripting language. And they use JavaScript to build the dialogues. I know you know what I'm talking about. Somebody email me with the answer. And I want to go through like the phone on media stuff and kind of advanced threading, some more model view stuff. I'm thinking about doing Android with Lighthouse, but I'm just not sure because I've got an Android book and it really stresses use Java. So I've been kind of reading up on Java a little bit more. Anyways, I'm battling, taking up your time. Thanks for watching.