Showing posts with label security. Show all posts
Showing posts with label security. Show all posts

Thursday, October 08, 2009

Macware for Mac Security!

It is interesting that more and more recently--well hold that thought, maybe now I am caring more about what is going on with Macs than before? Anyway, more "security" focus is being given to Macs, why? We know why, experts have been saying why for a long time.

"Macware for Mac Security"

"We hope Mac users across the globe enjoy the variety and value being offered in this bundle."

The Mac Security Bundle contains the following programs:
* Macware WebGhost5
* Intego VirusBarrier X5
* Micromat TechTool Pro 5
* Absolute Software Computrace LoJack5
* Intego ContentBarrier X5
* Intego NetBarrier X5
* Smith Micro Spring Cleaning
* JoeSoft Klix
* Intego Personal Antispam X5
* Intego FileGuard X5
* Intego Personal Backup X5
* MOApp MyWallet

I guess Justin Long on Mac vs PC commercials just gained a little more weight with "Bloatware." I just find it annoying how Apple just won't come out and state the obvious, "we're sorry people, our commercials and mass marketing campaign were very misleading."

Friday, October 02, 2009

On Computer Security Concepts & Practices

[Disclaimer: I do not claim to be an expert on IS or IA. All information provided are for informational purposes and as a foundation to an opinion rather than any form of academic reference. Please use the references that are provided to make further use of the information contained therein. However experiences in the field of networking and computer security in my specific environments have prompted me to document the information in this post.]

Security. It's on people's minds when surfing the web, using a network or concerned about privacy. It permeates our communication, transmissions, and even some daily routines. On the computer spectrum, since in most cases the end-user is running a Windows Operating System it is reasonable to conclude, that it at least crosses every computer user's mind at one time or another, "am I safe?"

I think there are common misconceptions thrown around on forums, social networks and among PC/Mac flame wars. Often the terms security, exploits, vulnerabilities etc. are thrown around often with loose meanings. I've often seen, 'if the PC users would switch to Mac, there would be a lot less problems with [insert exploit here]." Now this is not to say these comments are coming from security experts and those that should know better, at least I hope not. But judging by the comments I've witnessed, they seem to be misinformed people speaking to a misinformed audience.


First of all, why are there so many vulnerabilities constantly being found on a Windows OS? Well instead of simply looking at the way Windows operates, let's examine why a vulnerability exists in the first place. But if we're going to talk about vulnerabilities we will definitely need to talk about exploits right? And if we're going to talk about exploits, there would be reason to speak about payloads! We know vulnerabilities exist. We know exploits take advantage of those vulnerabilities. We know that the payloads determine how severe the vulnerability eventually becomes. So instead of talking about Windows containing "buggy or flawed" code or that it has a large market share or whatever other reason is often given, let us talk about more of the principles of security than the results of vulnerabilities, and perhaps it would give us a better understanding of why they exist anyway.

From my personal research and observance, there are three main divisions that in one form or another involve security; Computer Security, Information Security, and  IA (Information Assurance). Of course we as computer users are primarily concerned about computer security, though it is not unwise to also gain a little bit of knowledge on the other two. For two reasons: the first, computer security is actually a branch of IS, and second, the other two existed before or at the birth of computer security. So even though they are not the same thing, some fundamental things are shared among them either slightly modified or for a different purpose.


Let us first look at Information Security. Information security has existed for as long as any sense of "privacy" in humans has existed. Whenever it was that the first human breached trust, violated someone's privacy and exploited the information, you can bet that people began to worry about security. This really became apparent when the mechanism of writing became a common tool to use in  communication. Then when a mechanism for transmitting these messages were used (smoke signals, runners, coaches, letters, electronics etc.,) the need for security was obvious. It was much more evident throughout history of its importance when wars began. Intercepting information, breaching physical locations, and interrogation only magnified the need for security measures.In order to avoid some obscure history lesson, the point is, "security" has existed a long time and from the beginning there has also existed "vulnerabilities" and "exploits" for such measures. People that implemented their forms of communication, information sharing and security did not take sides in flame wars, "my smoke signal pattern is more secure than yours!" Rather as computer security enthusiasts should be, they focused on the truth, all security is penetrable.

An example, would be the well known Caesar cipher. I say well known because I think at one time or another, as children we've all seen "decoder" items or toys in cereal boxes or a box of Cracker Jacks, those were based on that particular cipher. However given its simplicity, this way of protecting information in that environment was possibly very effective. The reason I say "environment" is because of the type of people he was trying to keep out of his information. Did they know the cipher? Probably not. Was it a highly common thing among those he was protecting information from? Not really. Some scrambled letters could have easily looked as a different language and have been unusable to his enemies.

Even though it is a primitive form of "encryption" an equally primitive form of Brute Force attacks were its exploit to the vulnerability even back in 50 B.C.! Technically speaking, if you came across such an encrypted message in our day, you'd understand it was encrypted. You wouldn't know immediately though what encryption nor what algorithm was implemented, but you could guess. In this modern age, we have a wide range of access to free information, it would take a relatively short time to figure out what sort of encryption is used on a message. Really then, the principle has not changed. It is not a matter of how but when. Given enough time, anything can be cracked, but fortunately for most modern encryption, time is something humans do not have. So is the vulnerability gone? No it is not, but instead it has been made very difficult. So do any other vulnerabilities exist with modern encryption? Yes. One need to look no further than the software that makes use of the encryption, or better yet, the users. It has been proven often that social engineering is a formidable foe and it will continue to be so until humans are no longer prone to make mistakes, ever.

[For further insight on the discussed subjects see the following links: Encryption, Introduction to IS, and Software Security Engineering by Microsoft ]

There of course is much more to the workings of IS (e.g. hardware, physical, software) but is well beyond the scope of the point in this post.

Note: Information Security is modeled on three main components, which are discussed under the next heading because of their close relationship.



Now let's look at Information Assurance. With IS, we were a lot closer to the security of information, but with IA we are actually a bit higher and further from operation. This is because IA takes in a broader sense of risks that not only involve security, but availability, privacy, integrity and authenticity. There are actually a few more areas in which IA's scope manages but for this article, we do not really need to touch on them. Since it is closely related to IS, I will use the CIA model of IS (not the government agency) to display a common core of components.


The "CIA" model consists of Confidentiality, Integrity and Availability. These are the main principles adopted by IS but also instituted within the IA model of principles, as I said, we are further back from the picture looking at a broader sense of information.

The basic functions of IA is to assess the object that is being protected. Remember, not only protected in a security format, but also from disaster, manipulation and availability. (Privacy, Integrity, Availability.)

Once it is decided which assets are to be protected, it is next determined what possible risks exist, ultimately worst case scenario.

When such an evaluation is done, the IA personnel will provide not a solution simply to "proof" the information from any of the above already existing vulnerabilities, but to manage how to best protect the information with the least TCO. Not only financially, but legally (broad sense) and effectively keeping availability.

If you notice however, why isn't an effort to "100% proof" a system performed? Because quite frankly it would be unreasonable to do such a thing. Not only would it be unreasonable, but consider the resources it would take at the expense of TCO; and yet the system would still prove to be penetrable. Furthermore, have you observed a system that is vulnerability proof? It then seems logical to conclude that based on these two core principles, our argument should not be on who has the most "vulnerabilities" or "exploits" but rather on providing and making use of the security and other resources immediately available!

For further reading, the following links may be of interest: Department of Defense IA Implementation, DoD Intructions, Bella-La Padula model, more on Computer Security models. Here is a paper on general security models, including the previously mentioned at crazylinux.net


And then there was Windows. After these two brief non-exhaustive presentations, it would be foolish to sit on a particular Operating System because you think it is "more secure." You are lying to yourself. Rather you should be sitting on an Operating System because of your observance of how closely the above principles are applied, but first of all with yourself. Whether at the developer level, or at the end-user level, security measures can be implemented to a respectable degree that would make even the would-be hacker nod their head in respect. Even though still penetrable, respect for security as a whole would protect you in most cases. After all, it was respect for security that moved the above principles to be developed and implemented.

Though, back on the subject of the Windows Operating Systems, again, why do they have vulnerabilities? Is it simply because the code is "bad" or because another OS does a much better job? Or could it possibly be because it is well known? Is it because it is a target? Is it because the weakest links are easier to predict than are the encryption schemes? I believe these questions should provoke objective thinking on the subject on an individual basis rather than uninformed generalizations.

The fact and theme of this post remains the same, from the ancient days of security, though it has evolved over time into different forms, the reason it has had to change has never changed itself, vulnerabilities exist in all of them and unless people cease to look for them, they will always exist. The more services are accessible, the more risks open up for breaching. The more exposure, the more chance there is. The more we think we are "safe" the more insecure we become.So again, it is not a matter of if or how, but a matter of when.

Thursday, October 01, 2009

Charlie Miller on Mac's Security

Here is a couple of more sources to further show my point's validity. Don't be fooled by their marketing, Mac OS is setting itself to get owned further as their share increases.

http://blogs.zdnet.com/security/?p=2941 Charlie Miller explains exploits in Mac OS

http://www.tomshardware.com/news/hack-windows-security-snow-leopard,8704.html Charlie Miller convinced

Interesting how this supports what I said in the previous post:

"they are indeed setting up to crash and burn when they jump into the lake with the Big Fish who have been swimming with sharks for over two decades."

The question we should ask is, why were these exploits so easy to use? It's a good question, because the answer reveals Apple's pretense and attitude toward security flawed in principle.

Wednesday, September 30, 2009

Project Natal & Xbox 360 Security

Microsoft recently, well not so recently anymore, June 1, 2009 @ E3 2009, announced their new project, "Project Natal" and their new "controller-free gaming experience." Even though it was announced a few months ago I just now found out about it whilst looking at Wii motion enhancing add-ons.

If you have not yet heard about it or seen the demo then check out the multiple demos on Youtube here:


Anyway, in all the articles discussing Project Natal and the videos showing the capabilities of this device Microsoft is working on, they are all discussing how "immersive" it is. It is true, as proof look at how well Wii has done for itself in sales because of its relative immersion quality and plain fun factor--the kids love it!

I mean when you have a "game" that "recognizes" you by either your face or your voice as soon as you walk by, and can greet you by name and "interact" with you. Furthermore, when it can also detect your tone (according to the Lionhead demo,) and even make 'eye contact' one has to wonder about security. However from what I have seen, no one is worried, yet. I've searched for articles thinking that perhaps someone may be a little concerned about security with this technology in your living room and surprisingly found none. Granted it was only recently unveiled so perhaps it's still too new or no one wants to jump the gun just yet until more details are released from Microsoft. But I am such a person willing to speculate and perhaps even predict a few security risks that may present themselves through this new toy.

First of all let us look at what this device consists of:
  • Microphone (multi-array, to detect multiple voices/persons with noise canceling)
  • RGB camera
  • Depth sensor (obviously to get a better "image" of you 3 dimensionally)
  • IR + CMOS sensor (for those dynamic lighting conditions, even in the dark)
  • Feature extraction (with 48 skeletal human body points)
  • And network ready (presumably from the demo of conference chats through Xbox Live)
 I don't want to drag this post too long (we've heard that before) but I apologize now if I do, I tend to write with train of thought, but these things need to be considered even if you don't care. Having this in your living room is no different than having a webcam installed on your computer, either built-in or not. The potential privacy risk involves the obvious, someone hijacking your webcam to snap pictures of you and perhaps using the common built-in microphone to eavesdrop as well. Report 1, Report 2

Even though those two reports are basically over someone taking video or pictures of you without permission, imagine how much more a device like the Project Natal device could do. We're not just talking about some fuzzy out of focused pictures here. We're talking about being able to detect who is who by sound or video and facial recognition--even in the dark! Other than the potential risk of invasion of privacy to eavesdrop visually or audibly, what other security risk could exist? That is up for speculation, we already know it could possibly be done on a regular Xbox camera if it could be done on a PC--after all, the Xbox is essentially a PC. It has software (the weak link here after users), hardware, GUI, Kernal and other critical "components."

 As further reason to not take these ideas so lightly right away, take a look at the first Xbox, and how bad it did in the security realm. Not only did they use a Windows Kernal and a similar bootup process, but the circuit board's actual bus from the famous "south bridge" was hacked to sniff the code being passed over. This was and is a hardware exploit. There was also the software exploits, where the saved games were not checked, nor was the data on the dashboard checked--which would result in possible buffer exploits. These are just two of the many exploits. Xbox 360 corrected many of the easier exploits but some remained, for example the DMA attacks due to it not being encrypted and the infamous Hypervisor exploit.

It must be acknowledged however that Microsoft has taken good measures to keep these gaming console/PCs secure from remote hacking, in fact most of these "exploits" are in forms of piracy and home brews and OS changes, not virus/trojan/code types. As regards their security measures, for example, the network it communicates with online is encrypted, with what? I don't know, maybe some custom SSL? I really don't know. Also, the network is obviously private. Another thing, the Xbox 360 basically has to authenticate itself before it's let onto this network, if it fails, you most likely will be banned due to modding etc.

Really, on a technical level, the only real ways to do any remote hacking like we do on computers is by first either finding a way into their network--which I believe would be damn near improbable; or find a way to impersonate and be authenticated as a 360 on their network; or formulate some sort of MITM attack allowing the real 360 authenticate you; or modify the 360 to let you use it for your hacking needs but then you also have to pass the mod checks; or somehow make use of the 'PC to Xbox 360' network capabilities. Then comes the problem of software to execute. Unless physically hacked, 360s will not execute software that is not approved, especially software that is not approved by Microsoft's Xbox Live market place.

Pointing out those few security measures that do protect your consoles may make us feel warm and fuzzy. However, we can start crapping bricks when they make a web browser available to the Xbox 360. It is not unreasonable to conclude that security itself is a reason the 360 does not have a browser. Once it does, it will become very vulnerable to malicious 3rd party applications, enumerations and hacks. Maybe then it will be time for a new sub-market? Norton Anti-Virus 2009, Xbox 360 edition?

In conclusion, while Project Natal may not go all Skynet on us all because of the security measures and more fundamental--the improbability of it, I believe it is shrewd not to dismiss such possibilities. When your Natal device is snapping Infra-Red-48 jointed-3D Rendered images whilst taking vocal samples and retina scans of you detecting your emotions through facial recognition, don't come crying to me I didn't tell you. ;-)

Tuesday, September 29, 2009

Apple's Security Pretense

Sure I may be on a roll here about Apple, I swear I don't hate their products, I hate their misdirection. Their products are "fun" as I recently described them to a fellow admin. But would I use them because Apple says they are more secure, immune to viruses, etc.? No.

Simply because there are far less cases on a Mac does not make it more secure. No more than me being a minority make me any less vulnerable to H1N1. When there is less of something, you are going to observe less things occur with that something. When there is more of something, well . . . you get the opposite. It's common sense, or so you would hope.

Quick example, there was a point in time in the last century when people very rarely ever heard of crimes as regularly as we do today. In most cases they had to observe it first-hand. Now, we observe it daily on the news and other media formats. However did it mean these crimes that were rarely heard of didn't occur? Of course not because they did occur. Granted, crime has gone up on a world-wide scale in general and the types of crimes have also increased into the technology realm, a "market" that did not exist a few hundred years ago on a binary level.

But this is the pretense that Apple is playing and has been playing for quite some time now. "We are immune to the viruses that PCs become infected with," or "OSX is far more secure than Windows--it's UNIX based!" and so forth. How long will Apple be able to use that as a crutch though? And is it true? Again, yes and no. Yes they are less affected by the common security problems plaguing Windows and perhaps Linux operating systems, but is it because they are less secure? Well according to the following report, it doesn't seem that is the case. Marketshare.hitslink.com shows the shares each OS has for the past two years, since November 2007. Statowl.com shows another pie chart with similar results. I think it is a bit easy to understand why Macs may seem "more secure" don't you agree? They don't have much market!

Why is this small point of any use to us though? I'll tell you. The question begs to be asked, how many average Mac users have spyware software installed, updated and running? How many perform the checks on a regular basis? How many actually have any anti-virus software installed, updated and running regularly? It would be a tough call to guess on these questions. But if I had to place my money on a bet to see which user has either of these things installed meeting the above conditions, either a Mac or PC user--you bet your lucky stars I'd put my money on the PC user. See here lies the future problem of Mac. As they continue to gather a following of "Hi I'm a Mac!" consumers, they are possibly also setting them up for a future of failure due to being unprepared. After all, why do Mac users need to be fearful of being on the internet when they are "immune" to all the problems a PC has? After all, wasn't it Apple that says, "so you can do anything — without worrying about losing everything"?


So while Apple's Macs begin to no doubt gain market share increases and a bunch of loyal customers, they are indeed setting up to crash and burn when they jump into the lake with the Big Fish who have been swimming with sharks for over two decades. Mac users in general are still green when it comes to having to worry about security, hackers, spyware and viruses.


Proof of this is here in this article at SecurityFocus: http://www.securityfocus.com/brief/864 All of a sudden Apple "encourages" their users to look into using virus software, and you know why. The interesting thing is how they removed the article as mentioned elsewhere at SecurityFocus as well: http://www.securityfocus.com/brief/866

Of course there are plenty of people that will dismiss the "Market share theory" and call it a myth or speculative ideas. One forum on Apple's website had a poster say, 'this myth cannot be proven until Macs have 96% of the market share to compare to Windows.' It may sound reasonable, but it still does not negate the equally reasonable suggestion that Mac is in knee deep prospects of plenty of security problems of their own in the future. Consider the latest article as further evidence of these things being the case and the exact reason security experts and PC users have been saying what they have been saying:

http://news.techworld.com/security/3202856/russian-hackers-target-macs/

It seems all that is needed is some incentive, and Macs finds itself in the same boat as Windows, except with a lot less experience and awareness among their users. In the distant future, to me it seems the "security" pretense that Apple currently uses as a crutch will soon catch up to them. If you are a Mac user, take the expert's advice, do not ignore security just because Apple makes you feel warm & fuzzy for now. Good luck.

Apple's Mac FAQ & Marketing

"Macs don't have problems like PCs do."

Now most of us know how such a statement is based on uninformative Mac commercials and large scale marketing tactics on the part of Apple. Literally brain washing the average consumer that Macs a) "don't get viruses" b) "More secure" "Immune to Spyware" c) "It just effin works."

Most computer savvy folks though will understand these commercials for what they really are, just commercials, marketing tactics--not commercials being informative of their product. So you would guess Apple's website would at least have good  information to not mislead the consumer. Well let's look at a few of the "FAQs" at the Apple website.


"Is Mac safe from PC viruses?"

One does not need much thinking power to realize this question has been legally and strategically devised to include the specific form of viruses, "PC viruses." But Apple takes it further, under the question it says:

"Yes, a Mac is 100 percent safe from viruses designed to attack PCs."

Can anyone say "DUH"? It's like saying, "Is a PC safe from Mac viruses?" And then replying with, "Yes, a PC is 100% safe from viruses designed to attack Macs." One can only correctly assume the nice play of words done here, by using legally protecting sentence structures and the positive sounding "100 percent" catches the consumer off guard and buys into the whole BS that Apple is trying to sell you. Yes I am talking to you. It's okay, it happens. Under the same question Apple goes on and haphazardly "explains" (it's really legally protecting themselves) how all computers on the internet are not immune to viruses or spyware, but that it is based on a "UNIX foundation with security in mind." So if it is UNIX that is at its foundation, why is that relevant to the gist of their point? If anything, saying it is based on UNIX foundation, it makes it all the more so plain to see how vulnerable it can be to many of the same exploits and viruses. After all, in theory, hacking Mac is hacking (an already often exploited UNIX) right? It gets worse, Apple goes on to further add to this apparent disclaimer saying how it has built-in software that "alerts" you when you are downloading applications and how Apple makes "free security updates" for their users. Wow, how revolutionary, don't all Operating Systems do that? My Windows does, and I'm sure that guy's Linux distro over there does too.

The FAQ goes on.


"Will my PC devices (cameras, printers, hard drives) work with a Mac?"

 Mac says an emphatic Yes! But wait, that is not all:

"Mac is smart enough to know what to do when you plug in your digital camera. . ."
What does it do that makes it so smart you might ask? Apple provides the answer, "it opens iPhoto to import your pictures." Can I get a face palm anyone?


"Is Mac Reliable?"

 Apples doesn't really answer the question on that one, rather it makes use of the ad hominem argument in a form of a genetic fallacy (as in most cases). It starts off with, "When you buy a PC. . ." and explains how the hardware may be manufactured from a different company than the software and Mac isn't this way, (this is also a half-truth). It ends the side-stepping with:

"Occasionally an application might quit, but it won’t affect the rest of your system. And Mac OS X resists most viruses, so you can do anything — without worrying about losing everything."
Of course let us call it "quit" and not "crash" or "freeze" as you have just described the process a PC would do with an unresponsive application. However, most Windows PCs do not completely crash your Operating System because of one failed application. In fact, it does the same exact thing Apple is claiming Mac does, it will quit the faulty application and not affect the rest of your system. The last sentence is laughable, no counter argument needed.


"Why should I spend more money on a Mac?"

Good question! In my personal opinion, the only reason you should have to pay more is because it is pretty. I admit, most products from Apple, come out their orifice looking like a gem. But that's just the outside casing only, seriously, if you've seen one hard drive, you've seen them all. I think the word we are looking for here is, aesthetics. But I don't believe you are paying more for the reasons that Apple claims in their FAQ:

"When you compare the cost of a PC and factor in the additional software, memory, and other extras you have to buy to go along with it, the difference in price between a Mac and PC isn’t as great."
False. It is a huge damn difference in price even after I choose supposed "extras" on a new PC. But then again, we are comparing Apple & oranges, (I'm not sure if I intended pun.) Here is what I mean, the hardware is not comparable to begin with! I took some time to investigate their claim and surfed around their website and looked at what products they have available. The only one that didn't look like a flattened toaster (sorry Macmini) and provided scalability and somewhat of a workstation looking case was the Mac Pro. The specs on these beasts are amazing to say the least! We're talking about Quad Xeon cores, tons of memory (6GB+), tons of storage and so on. Well no wonder it is so damn expensive! It has nothing to do with what Apple claims at all. You are getting Workstation-Class power in these machines, power power power. However Apple is not telling the consumer that they don't need all this power. Seriously, a guy at home that checks his email, surfs the internet on Safari, downloads pictures, porn, burns CD/DVDs, watches movies, listens to music and uses Microsoft Office for Mac all on the same computer and even at the same time does not need all the hardware the Mac Pro sells you, period.

Back to the claim that Apple made though about the price difference not being that great after you supposedly add much of the features the Mac has already. I put this claim to the test. I opened up a Dell Workstation page (which I think was a somewhat comparable computer to the Mac Pro) and I opened up the Mac Pro configuration page as well. I based the Dell workstation off the default Mac Pro "8 Core" configuration. By the time I was finished, I saved almost $1,000.00 with the Dell workstation for the same specifications if not better. The Dell workstation has a bigger hard drive, it has a better nVidia video card, 64-bit OS. Additionally, if I wanted to match the Mac Pro price, I could easily include Microsoft Office 2007 Professional, a RAID controller, a second HDD and possibly a second LCD monitor and still be at the same price range as the default configuration of the Mac Pro.

I don't want to drag this particular point on, but we also need to talk about the software. Further under the same question Apple states that the price is also due to the already built-in software that lets you do so much. What applications? It doesn't say, but if it is implying the applications that are often advertised to lure people, those aren't free. They are in fact, add-ons, the very thing Apple attacked the PCs for. So really you aren't getting crap other than an overly powerful computer that you probably don't need as an average consumer.


This brings me to my last point on this portion of the FAQ. There is no variety of desktops or workstations to choose from at Apple. It does allow you to "customize" the configuration as do other PC manufacturers do, however based only off their one model (Mac Pro), where as with PC manufacturers you have a wide selection of PCs to choose from. I already hear Mac lovers saying, "Apple doesn't need to make a bunch of computers, because the Mac Pro can do it all!" Well that's a yes and no statement and equally a catch-22. Let me briefly explain.

You can have a computer that can "do it all" and be stuck with a huge price for something you will be utilizing about very little of. Or you can have a PC that can do what you need for a fraction of the price while you utilize most of its resources. If you later decide you need more power, you can upgrade. Need more memory? No problem, it's cheap nowadays. Need more storage? No problem, hard drives are cheap too, and so are external portable hard drives. Yes they are cheap, not expensive like Mac wants you to believe. The point is, it is an unnecessary waste to have such an extremely powerful computer--it's overkill for most consumers. And remember, CPUs and RAM perform dynamic volatile functions, they don't "fill up." They are used on how much work you are actually doing at any given time.

So why are you paying more? Because someone has to pay Justin Long to act witty and cool in their mass scale marketing. Someone has to pay the design department for their cool looking cases and colorful gadgets. Someone has to pay their adapter department to invent new proprietary connections and cables. Finally, someone is going to pay that much for a Mac. 

Stay tuned for my next post, it will be much shorter, I promise.

Monday, September 21, 2009

Python: Intro, cytpes, farts

So past couple of weeks I've been working on Python trying to learn this language. In fact I tried it a few years ago but I got distracted and put it on the back burner. So currently I am back on track giving this another attempt. Here is my disclaimer: I am a Python novice. Anything I say for the time being regarding Python are just my experiences and for documentation purposes. As far as facts, I am making the best efforts to try to make everything informative and accurate.

The reason I'm choosing Python treads along the lines of it being easy to read the syntax and in my opinion, seems to be a nice stone-stepper language (among the common reasons: exploits, security, etc). It also has a nice library set and can produce language that is compatible with C.

For instance, we could easily use a CTYPE module in Python to call functions in DLLs. Using the method cdll() to call functions in the C runtime DLL, MSVCRT.DLL. Namely, Microsoft Visual C++ Runtime. This is obviously a Microsoft library with C++ runtimes. I didn't know that specifically before.

So from what I gather, the C++ library just mentioned, can be used as sort of a reference for your Python scripts, to "call" functions within that library that will assist you in carrying out whatever it is you are trying to do, without have to use a C++ programming language.

For example, below is some code (novice) that does just that:
--------------
from ctypes import *

msvcrt.dll = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s", message_string)
--------------
What this should do for you is output the text, "Hello world!" Pretty easy no? If you read the code, you can notice how you are telling the script to use the CTYPE module and to call the printf (in the C runtime) function using the cdll() method to output the words inside the first set of quotes. A similar thing can be done with this simple line of code just using Python alone:

--------------
>>> print "Hello world!"
Hello world!
--------------
The difference was, the first example was to show that you can easily access the C runtime library to use its functions to accomplish tasks with Python. What this seems to implicate thus far is that instead of just being limited to this small Python language, you actually expand you resources and arsenal by using other libraries that already exist in the operating system. If you think about it, that is a powerful thing, sploitz anyone?

Now considering how new I am to higher programming languages in general, I did make a mistake with the above code in example 1. After checking spelling and syntax over and over I was about to pull my hair out before learning a valuable lesson. It is case-sensitive. Of course I knew that, but it completely eluded me and one hour later, I did a face palm.

The reason the code was not running was due to a very simple mistake. It was in the line, "from ctypes import *". The F was capitalized and was causing the program not to "expect" the  command as it literally informed me of. Humorously, it attempted to tell me what it did "expect." Something to the lines of, Python was "expecting //, if, or," etc. It gave me a list of commands and functions (a long one) in trying to tell me I was wrong. After figuring it out I felt I accomplished something even though it was my mistake, what better way can you learn than from your own mistakes?

Sorry if this post felt straight to the point, I am out of time today and leaving now. Anyway, this was just a short binary fart that the wonders of autonomous pressure releases of an admin learning a language results in. Did that even make sense? Probably not.


- - -
Vocabulary


ctype: Python modules that allow you to own


cdll(): Loads libraries using the cdecl calling convention


binary fart: invented by adminalive.blogspot.com, Copyright 2009 all rights reserved. (still figuring out what it exactly means >:-\) Usage: "I had a long binary fart that ones and zeros fell out my ass crack." OR "I barted."