hudsmack

Name: hudsmack
Joined On: Jun 22, 2007
Maintag: hudsmack
Age: 30
Occupation: Software Architect
Location: Phoenix, AZ
Currently: Offline
Last seen: 11/25/08

373 Member Points

View Members Homepage

My Gamertags

Xbox 360
hudsmack

PC
j0k3r

PS3
hudsmack

My Clans

07/18/07

Do we have any other code monkies in here?

Every once in a while I thought I might post some code tips.  The following code will check for read ACLs on a file in C#.  We had a situation come up at work where one of the developers was having a problem reading one of our log files with user permissions.  It turns out he was attempting to open the file using a full control access flag, but I thought this little piece of code could come in handy.

If you have any questions about the code, feel free to post in the comments and I will do my best to answer all the questions.  If there are any other code bits you want to see, let me know and I'll put some write-ups together.

using System;
using System.IO;
using System.Security;
using System.Security.Principal;
using System.Security.AccessControl;
using System.Collections.Generic;
using System.Text;
 
namespace TestReader
{
    class Program
    {
        static void Main(string[] args)
        {
            string myPath = @"C:temptest.txt";
            string[] fileRead;
            try
            {
                if (File.Exists(myPath))
                {
                    if (CanRead(myPath))
                    {
                        File.OpenRead(myPath);
                        fileRead = File.ReadAllLines(myPath);
                        foreach (string line in fileRead)
                        {
                            Console.WriteLine(line);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No permissions to read the file.");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
 
        }
 
        private static bool CanRead(string fname)
        {
            try
            {
                WindowsIdentity WinIdentity = WindowsIdentity.GetCurrent();
                WindowsPrincipal WinPrincipal = new WindowsPrincipal(WinIdentity);
                bool AllowRead = false;
                FileInfo fi = new FileInfo(fname);
                FileSecurity sec = fi.GetAccessControl();
                foreach (FileSystemAccessRule rule in sec.GetAccessRules(true, true, typeof(NTAccount)))
                {
                    if (WinPrincipal.IsInRole(rule.IdentityReference.Value))
                    {
                        if (((int)rule.FileSystemRights & (int)FileSystemRights.Read) > 0)
                        {
                            if (rule.AccessControlType == AccessControlType.Allow)
                            {
                                AllowRead = true;
                            }
                            else if (rule.AccessControlType == AccessControlType.Deny)
                            {
                                return false;
                            }
                        }
                    }
                }
                return AllowRead;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
        }
    }

}



Posted by hudsmack @ 11:08 pm EDT | Permalink | 0 Comments

07/12/07

Hackers

http://www.imdb.com/title/tt0113243/

Have you seen this movie? This is quite possibly one of the most technically absurd movies ever made yet I couldn't stop myself. I don't know if it was a weird infatuation with Angelina Jolie or the laughable way computers were presented, but it held my attention for the entire 107 minutes. Trust me, that's no easy task, I have ADD like you wouldn't believe.

I first remember seeing this movie when it was released back in 1995 and even then I thought the way computers were presented was ridiculous. Yet here I am in 2007 watching it all over again on my big screen at home while it plays on Showtime. The movie opens with our hero, Dade Murphy, being sentenced to probation for 7 years. He is not allowed to touch computers until his 18th birthday. He was responsible for the single most devastating hack in history that brought down 1507 computers including Wall Street systems which caused a *gasp* 7 point drop in the market. In addition to his probation, his parents were fined $45,000 which subsequently ruined their marriage. Now, we can all see the inane premise unfolding before our eyes.

Fast-forward to our antagonist, Plague, played by Fisher Stevens. He and his mistress have figured out a way to shave the cents off of thousands of transactions per day, and are quickly on their way to a fortune of $25M. The way he decides to cover his tracks is with the Da Vinci virus, which if executed, will cause the malfunction of 5 super-tankers causing massive oil spills all over our Oceans. Let me guess, you just said, "WHAT?!?!" too. Plague is "elite" though, so he has figured out a way to blame Da Vinci on the hackers in our movie and he is freely available to continue looting his money while the authorities have a single-minded focus on stopping Da Vinci.

Through the discovery of a cleverly named "garbage file", our protagonists figure out the whole plot and discover they are being framed. They unite hackers all over the world to crash the mythical great supercomputer, the Gibson. Even our hackers seem overwhelmed by the Gibson as evidenced by this little foreshadowing piece of dialog:
                                PHREAK
Look, you wanna be elite? You gotta do a
righteous hack. None of this accidental shit.

CEREAL
Oh yeah, you want a seriously righteous hack,
you score one of those Gibsons man. You know,
supercomputers they use to like, do physics,
and look for oil and stuff?

PHREAK
Ain't no way, man, security's too tight. The
big iron?

DADE
Maybe. But, if I were gonna hack some heavy
metal, I'd, uh, work my way back through some
low security, and try the back door.

During the hack of the Gibson we get some of the greatest dialog ever to grace the silver screen.
INT. COMPUTER ROOM, ELLINGSON MINERAL.

The big monitor shows the attack in progress.

MARGO
What is it? What's wrong?

PLAGUE
Nothing, it's just a minor glitch.

MARGO
"Minor glitch" with you seems to turn into a
major catastrophe.

The main screen is filled with:

I WANT A COOKIE. GIVE ME A COOKIE NOW!

HAL
There's a new virus in the database.

MARGO
What's happening?

HAL
It's replicating, eating up memory. What do I
do?

PLAGUE
Type "Cookie", you idiot. I'll head 'em off at
the pass.

Another virus appears.

HAL
We have a Zero Bug attacking all the login and
overlay files.

PLAGUE
Run anti-virus. Give me a systems display!

The systems display comes up. Red flashes everywhere,
signifying new attacks. Plague presses a key.

PLAGUE
Die, dickweeds!

HAL
The rabbit is in the administration system.

Rabbit icons start to fill the systems display.

PLAGUE
Send a Flu-shot.

MARGO
Rabbit, Flu-shot, someone talk to me.

HAL
A rabbit replicates till it overloads a file,
then it spreads like cancer.

MARGO
Cancer?

The Da Vinci Virus sings "Row Row Row Your Boat".
Tanker ballasts start filling - for real.



INT. GRAND CENTRAL PUBLIC PHONES.

KATE
It's the Gibson, it's finding us too fast.

DADE
Man, there's too many garbage files, I need
more time.



INT. COMPUTER ROOM, ELLINGSON MINERAL.

PLAGUE
They're at Grand Central Station, lower level.
Don't screw up.

Thanks to http://www.angelfire.com/co/aplacetocrash/hackers.html for the script.

This is a movie for the ages and certainly not to be missed. Make sure you check this one out,
you won't be disappointed.



Posted by hudsmack @ 12:01 pm EDT | Permalink | 0 Comments

07/11/07

Unreal Tournament III exclusive to PC/PS3 until '08

http://www.gamespot.com/news/6174170.html

"Today, the company revealed that it has also struck a deal with Sony that will certainly boost sales of its PlayStation 3 console. Today at Sony's press event, Mark Rein took the stage to announce that Unreal Tournament III will be exclusive to the PS3 and PC when it is released later this year, and it will allow the importations of mods made for the PC version to the PS3. That exclusivity will remain until "early 2008," when an Xbox 360 version will be released."

This is huge news for Sony and its lower than expected PS3 sales.  I am not a Sony naysayer.  Despite half the media boasting what a failure the PS3 is, I see awesome potential for the system and this just might be the game that pushes me over the edge of purchasing a PS3. 

I have been a monstrous fan of the UT series ever since the original and have been eagerly awaiting the latest offering.  Of course, I may just dump the money in to upgrading my PC so that it will run UT III.  I haven't quite decided yet.



Posted by hudsmack @ 6:18 pm EDT | Permalink | 3 Comments

07/11/07

Gears of War coming to PC

http://pc.gamespy.com/articles/803/803206p1.html

If nothing else, I will be buying this to play with the map editor and dig in to the Unreal 3 engine.



Posted by hudsmack @ 6:11 pm EDT | Permalink | 1 Comments

07/06/07

Microsoft Extends Xbox 360 Warranty

http://www.xbox.com/en-US/support/petermooreletter.htm

For anyone who has had to deal with the unfortunate experience of a bricked Xbox, this is welcome news. I personally have not had to go through the experience, but know several people that have. Microsoft's manufacturing and design have come in to question especially when compared to existing consoles. I have a PS2 at home that was purchased one week after the release date and still functions as it did on the day I bought it.

However, this move is to be applauded. Microsoft has recognized a problem and rather than bury it in bureaucracy and legal agreements, they are addressing it. This is most likely going to be a costly move for Microsoft...but hey, with Marketplace prices what they are, they can afford it. ;-)



Posted by hudsmack @ 6:56 pm EDT | Permalink | 2 Comments

66 of 70 of 70 First | Prev | Next | Last |

Blog Stats

Since 8/20/2006:

  • Viewed 4510 times
  • Bookmarked 6 times
This month:
  • Viewed 17 times
Subscribe:

My Consoles

Currently Playing

Friend's Posts

MML Season 2 logo
Caesar
(3:04 PM EST 01/07/09)
WEDNESDAY GAMING HEADLINES
TANK
(11:48 AM EST 01/07/09)
Just Great
Caesar
(11:14 AM EST 01/07/09)
MML Season 2 Getting Close (halo 3)
Caesar
(5:37 PM EST 01/06/09)
what to do
Caesar
(12:55 PM EST 01/06/09)
TUESDAY GAMING HEADLINES
TANK
(11:47 AM EST 01/06/09)
Opera
Caesar
(8:29 PM EST 01/05/09)
Lots to talk about
Caesar
(12:14 PM EST 01/05/09)
MONDAY GAMING HEADLINES
TANK
(11:48 AM EST 01/05/09)
Monopoly Maniac!!!!!!!
Caesar
(6:18 PM EST 01/04/09)