By changing where you'd want to put in grep-i anonymous, you'd do grep-i failed or refused. You could pick up any failed or refused login attempts to the FTP server. So basically you can just filter your logs like that. It's a little bit easier for some people who might be new to the OS X environment and who aren't used to using Linux or Unix environment in terms of checking their logs and everything. Basically, you could also modify the script further to perhaps beep or send out an email alert if you have multiple login failures, stuff like that, just for basic system maintenance. As far as AppleScript goes for an attack tool, it can be used, definitely used for attack means on a Macintosh system. Excuse me. Basically, over the past few years, there have been a couple AppleScript trojans or viruses that have been used to attack your OS X environment. But they mainly only do one of two things. They either take a look at the system and just mess around with files, you know, delete stuff, or else they exploit a scriptable application, where a scriptable application would be any application on the system that accepts Apple events and thus AppleScripts. Basically, in terms of some different attack methods that could be used, the Mac.Simpsons AppleScript worm that was released about a year ago, I believe, basically duped gullible users. into downloading and executing the AppleScript, which was included as an email attachment. Once it had done that, it popped open a Simpsons webpage and went from there to open up Outlook and send itself out to everybody in the address book, just like any typical Microsoft worm does these days. So that was exploiting Outlook's scriptability in terms of the Macintosh there with the AppleScript. In this case, pardon me, another similar case there was Eudora had a similar exploit, a few years ago, where basically it accepted AppleScripts and then could be used to send an email out without the user knowing, of course. Luckily, there was no malicious payload included in either of those basically worms that I just described there, but it would have been very easy for them to modify the AppleScript a bit to, say, delete documents or something like that while the AppleScript was running. In OS X, especially with the Unix commands, that can be particularly destructive, and I will demonstrate that. Right now, basically I'm going to open up my system here real quick and open up documents. Let's see here. Okay, we have some basic stuff in here. We'll duplicate this copy of my speech here. Save the real one since I don't want to lose it. And we'll duplicate this iTunes folder right here. So basically we have some stuff sitting in my documents folder right now. If we go ahead and run an AppleScript, again using shell commands, basically... we're going to clear everything out in there. So, rm-rf, and then tlday slash documents, which will remove everything in my documents folder. And if you take a look then, there is no documents folder, period. That could be especially destructive if somebody went ahead and made another scriptable worm that exploited even mail or something like that in the OS X environment. It could easily be put to use in terms of destroying. Files on the computer are even worse, downloading the various password files, anything like that. As far as going ahead and exploiting a scriptable application goes, it's very easy to do. It's as easy as going up to file when you're inside the script editor. And you go to open dictionary, just like this. And as soon as my G3 here catches up, maybe. Anyway, it will bring up a list of dictionaries. And these are all the applications on your system that could be scriptable. So you go ahead and you pick one, let's just say Internet Explorer, and it will open up a dictionary for that, which you probably can't read very well, but it basically gives you a list of things you can do with this. You could open up a URL, you can close all windows, activate it, all of these things. And if you go through different scriptable applications, you will find ones that you could export. Possibly sending out mail, going to a web page with some malicious Java embedded in it, something like that. So that's a very easy way to go ahead and just find out what applications you can script. And that gives you the whole dictionary you need there. As far as OS9 is concerned, going back a minute there, OS9 had some pretty scary scriptable applications. The Keychain Manager, for those of you who do use it, it's basically you take a key, which is your password, and you put it on the keychain and you lock it in. You lock the keychain with one other password. All the passwords that are on it are encrypted. The thing is, it's not necessarily locked. And if it's unlocked, anybody can go in with AppleScript and delete all your keys, download your keys with your passwords, anything like that. The Keychain Manager is present in OS10, but it is not scriptable as of yet. So personally, my opinion on that is that it's better for any method where you just encrypt your passwords. Someday the encryption is going to be broken. So my opinion, it's better to keep your passwords where you know they'll be safe, which is in your head. If you continue on with permissions of OS10, they play a big role in exploiting any of these scriptable applications. For example, the permissions with NetInfoManager, by default, are those that you can get basically the password list of all users on the system. So we're going to do another shell script here. Network, InfoManager, Dump. And then we're going to dump the password file here. And when we do that, you can't really see that, but we have the list of password hashes for root, as well as other users on the system that were enabled, and those would be crackable then if you used crack or anything else. You could very easily incorporate this AppleScript into a small Trojan and have it send the password file remotely for cracking on your own system or, you know, an enemy system, and then go ahead and log in remotely. In this sense, you could access the NetInfoManager, information there, if you have local access and a shell access on the machine, but sometimes you do not have that, and that would be possible then to go ahead and get into a system. I do have that as proof of concept script that I've flushed out from this. Unfortunately, due to time constraints, I didn't get it on the CD in time, but I will have it available for anybody who'd like it. Otherwise, it would be on the DEF CON network for the whole weekend. Moving onward, AppleScript can be used as a defense tool. Basically, AppleScript can be used to check and kill processes running in OS X. So if you notice a process that shouldn't be running, you can go ahead and, again, using terminal application, and I don't have anything running. But if I had had anything running, you can go ahead and kill it by just typing kill and then the process ID in an AppleScript. You can also do this to list applications that are running. This is a non-terminal one, again. So this is going to be, let me see what I have here. We're going to tell the finder to list all of the applications that are running right now. And here we have a list of basically everything that's running on the system right now. And you can go ahead and get the process ID then and cause any of those to quit. So basically, you can keep up with what's running on your system, again, with AppleScript showing its robustness in this. You can display a list of users just by using the normal finger command in a Unix shell, which you can do with AppleScript, of course. Basically, I realize that these are all Unix commands that can really easily be done in the terminal. But when combined with AppleScript and maybe put into a nice GUI, they do turn into quite a nice little program. You can just do, you know, one click, check your system. It's also good for people who are new to OS X. Anybody who's really migrated just over from OS 9 without any Unix background, it does help them get a little bit more accustomed to it. As far as AppleScript security practices go, a general rule of thumb is not to run compiled AppleScripts on your system until you're positive you know what they do. For the most part, you know, that sounds like it'd be something that you'd normally do. You just check the source code if you can, verify that it's legit, and then go ahead and compile and run it yourself. Sometimes it's not so obvious, though, that a downloaded script is, or downloaded program file, whatever, is not an AppleScript or another malicious application, for that matter. In that case, you know, a malicious person could just change the icon of the item and make it look like a text file. In OS X, you could easily go ahead and make that AppleScript open up a text file, have, pardon me, a text edit, have some text listed on the screen, and go ahead and delete everything in the background. This is basically the way the Mac.Simpson's worm function works. And by displaying the Simpsons website, the user didn't realize that it was sending out the email in the background. So the script can be more than meets the eye there. To verify the validity of a downloaded file, just use the git info command in the Finder. Basically, let's do that right now. I'll just open up this DEF CON speech that I had before and git info. And it's listed as a rich text format document under the kind. I just want to make sure that it wouldn't say, you know, application or compiled script if it looks like a text file. You know, you should be fine if it's a text file. Other than that, you can go on that if you are going to run a compiled script that you know is a compiled script, think twice before running it. Just make sure you know who sent it to you, just because it can do some nasty stuff now in OS X. Another good idea is to change the permissions on files and applications in OS X that you wouldn't want other users to be able to access. Just use the chmod command. As far as looking towards the future goes, as OS X matures, AppleScript is sure to enjoy an even tighter integration into the OS than it has already. And as more and more software companies make their programs scriptable, the more possible exploits there'll be. As far as AppleScript, it can be powerful, used for good reasons or bad reasons, just like anything else. So in my opinion for this speech, I just kind of want to make sure people realize that AppleScript is a very powerful tool. It can be very good on the network, but it also can definitely have some bad consequences if you run scripts that really shouldn't be run. Right now I'm going to just demo a couple things with these scripts that I showed you before. Let me just kind of fix the font thing real quick. . Okay, going back, AppleScript can also be used to run shell scripts. It can execute basically any application and cause it to open. So if you wanted to with that password dump before, you could take it, get the password dump file, and then go ahead and send it to crack to start cracking password files. I was going to do that, but I do not have the copy of crack on my system, right now, so I can't exactly show you that. Overall, basically, I guess it's just mainly a concept of just making sure when you're programming, if you program for Macintosh, just make sure you think before you put in scriptable parts of your application. It definitely helps for those of us who do programming in AppleScript, but just make sure it doesn't do anything that could lead to a compromise in the system, especially mail programs. They do tend to have issues like that. Basically right now I've got, it's going to take a little bit of a break, I've got some books, Cara of Freaky from Freaks Mac Archives and securemac.com that he got from O'Reilly. I definitely do recommend O'Reilly's books, I guess. I use this one, as you can see, quite a bit for AppleScript. It's a pretty good book. Not much in OS X, though. But I've got a couple books that they gave him. So, okay, we've got Mac OS X Pocket Reference. Anybody want this? All right, I'm going to throw this out. I hope I won't break anything this year. Okay, throw another one. Oh, well, things can go far. Okay, throw one over here now. It's like a baseball game. Okay, we've also got a few Unix for Mac OS X. All right, I knew that one would draw some. Okay, where should I throw this one? We'll throw it over there. And that one, oh, that's just those stupid little postcards. All right, we've got one more. Okay, I hope I don't hit the projector over there. All right, one more. All right. I'm also supposed to give away these. I believe it's a tape drive, I think. Okay, I'm not going to throw one of these. So... Hmm. Okay, let's see. We'll do some question and answer stuff right now. So if anybody has any questions, if you have a decent question that I like answering, then I'll give you one of these things. Okay, anybody have any questions? You can go ahead with the dictionary and let me just show you real quick. If you don't see anything that's listed, these are the ones that actually tell OS X that, yes, I have a dictionary. You can go ahead and you can browse the system yourself. Okay, the question was... Okay, I see what the question was. If you're inside an application, you see where it says what it does, you want to know if you can add more to that. Without having the source code to the program, that's not really possible. Because it's just what... When you program a Macintosh program there, you'd need to say, okay, when you receive this Apple script, do this. And if you don't have the source code to that program to add that code, you can't do that on your own. The company or person who programmed the software originally could, though. As far as if you were making your own program, though, you could feel free to add it whenever you wanted to in terms of that. So if you want to come up here, you can have one of these tape drives if you'd like. All right. All right, any other questions? Basically, in the OS X Server version, there is a lot that's still with Apple script. I mean, if you have it enabled in your system, it can still cause damage if somebody runs it maliciously. I guess the only thing to really do is if you are running the server, you know, just make sure you know what you're running. For the most part, Macs are still secure enough that you can't just break into one without doing something like, you know, throwing a Trojan on the system first or having some services running that, you know, really... I mean, as far as Unix goes, yeah, if you run services, you might get hacked. But if you're smart about it, you might get hacked. But if you're smart and you have your last patches and everything, it really shouldn't cause you any trouble there. If you want a tape drive, you can have one too. All right, unfortunately, I don't have anything else to give out, but I can take more questions. . Actually, I really can't hear you. Do you want to come up here with one of the mics? The fans up here are kind of noisy. . . . . . . . . . . . . . . . . . . . . . . . . . . It will try and open it then as if it was, you know, a text file or whatever. It will not run the script, so basically we get a bunch of gibberish. That's the way it works for most of OS X in terms of changing the names and stuff. Any other questions? So you showed us how to get to the command line from AppleScript. How about the other way around? The other way around for getting... Sorry, my hearing's horrible, so... So you showed us how to get to the command line from AppleScript. How about the other way around? All right, the question was that I showed how to get to the command line from AppleScript and he was asking how about the other way around. Yes, you can. You can write scripts in the terminal. You can also just go directly from the terminal, I believe. Let's just open that up here. Not Internet Explorer. You have, by the way, SCPT in the extension of the browser. Okay, SCPT is the extension. The extension for AppleScript is what you said there. Basically, I believe it's the OSA lang, if I remember correctly. That will list the normal scripts that are listed, what you can use for the scripting system, AppleScript and generic scripting system. You can compile scripts in the terminal, although I will admit that I have not really messed around that myself too much. I do prefer the Apple Editor, Script Editor program just because I usually suck at typing, so I make lots of mistakes. But it is possible to go back to back, you know, compile something, and the editor that can execute terminal commands can, pardon me, that's something that Terminalock can do, AppleScripts, so that is right, that can do that. Any other questions? Pardon me? OSA script. Yes. Okay. Any other questions? In terms of accessing, okay, the question was accessing applications. Okay, there's actually a lot of different general commands that a lot of the applications hold. So when you go to open up something, let's just go back to, let's say I choose this. In this dictionary that comes up, we basically have a list of the subset of the standard commands, which are basically the same for the whole system. Then each one has its own separate ones. It might not be the same on all systems. Specifically, Apple System Profiler is the report one on here. But you can access a number of general ones that are the same throughout the whole system. Is that pretty much what you're wondering about? Okay, in terms of security, accessing between two applications. You can use it to access different applications, you know, cause them to run, whatever you want, unless the permissions are such that... If you're a user that's logged in and running the Apple script, you can not run that. So for the most part, it is open that you could run between two applications, and that does have some security issues inherent to that. Yes, you can run scripts as different users. You can, right now, the terminal commands are a little shoddy still in OS X. Just the shell that you get that Apple script executes with is not, you know, it's not going to give you a full-fledged command over the system. There are ways, I believe, I'm not positive on this, to pass. The password along with the shell commands, you can change, you know, switch users and execute something like sudo, or whatever you want to do there, so you could execute something as root, yes. Any other questions? Okay, he was asking, do you have to set an implicit quit at the end, when you, like, say, open up the Apple remote, or Apple system profile over there. When it accesses it? For the most part, no. Because I was accessing it for its dictionary, it opened it up. If you're running a program that would access it, and just get some information of it, sometimes it won't even open up the program, unless it needs to actually access something in terms of opening, probably got lost there. Basically, what you do there is, yes, sometimes you do need an implicit quit, if you're going to want the program to close, but there are, I believe, a number of scripts that you can run, for the most part, where it would not even open the application. It would just pass the argument right through to a, you know, a, you know, a, you know, whatever you want it to be sent to. Any other questions? Okay, over there. Can you embed Apple script into an email? The question is, can you embed Apple script into an email? You can attach Apple script, but as of now, even with the mail program, you can't actually embed something in the email that would run. You can, however, have an Apple script that, say, would find a certain email, and you could have it be pulling the mailbox, and when it sees that email, it could execute then. So if there's something on the system, you could have something along those lines, yes? Okay. Alright. Anybody else? Back there? The question was, are there any known exploits for Apple scripts with Apple events, you said? Okay. I actually didn't catch that last part there. Okay, remote Apple events. Right now, there's none that I know of, although if you're letting remote access to your system in any case, there are definitely some security issues there. Okay, what he's talking about there, let me just show you real quick, is under the network, pardon me, not network users. Why am I confusing myself now? Sharing, okay, yes, it's been a long day, I drove 33 hours to get out here. Okay, you can allow remote login as well as allow remote Apple events. It allows users to send Apple events to your computer. Yes, that could be a security issue because you could send anything from a shutdown command. The core of Apple script is Apple events, which, so basically any Apple script you could do, you could do with an Apple event. It's a little bit low level in terms of the programming for that, but yes, that would definitely be a security issue. I do not know of any exploits per se, though, that are out for that. Okay, anybody else have any questions? Or are we all ready to go drink and party tonight? All right, well, I'll wrap this up, but I am going to be available for any questions. If anybody has any, I'll be around. I'll be here all weekend. I'll probably just be going over to the seller's area right now, vendor's area.