Impersonate - accessing a network folder from .NET

Thursday, 8 May 2008 09:22 by Myself

This is and neat class I've put together that allows you to specify username and password (and optionally a domain) and act under that identity. Primarily to access a shared folder, but you could easily find more areas of use.

   1: using (new Impersonator(true, "username", "password", "123.123.123.123"))
   2: {
   3:     // The new idenity is only active inside this using clause
   4:     if (!Directory.Exists(@"\\123.123.123.123\Foo\bar"))
   5:         Directory.CreateDirectory(@"\\123.123.123.123\Foo\bar");
   6: } 
   7:  

It makes use of the Win32 API "LogonUser".

Download the source code and give it a try!

Impersonator.7z (3.60 kb)

Tags:   ,
Categories:   Development
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Resolve GTA IV freezing issues (PS3)

Saturday, 3 May 2008 22:24 by Myself

I've had my PS3 lock up on both GTA IV and NHL08 today, I switched to NHL after GTA had freezed three times. Outrageous!

Edit: There is a easier method you should try first and see if it helps you out:

Those who experience lockups when playing the game (at least on PS3), DISCONNECT your lan-cable or log out from PS Network.
There's something that makes the game freeze once it is going online and/or you have e-activity going on in the background of the game.

As always, proceed on your own risk. Back up all your save games to an usb key chain or something, unless you want to lose it all.

Methods that may fix the problem for you.

1) Delete the game's install data. This is done via the PS3 options. Scroll along the cross media bar until you reach the 'Game' tab, now scroll up / down the list until you reach the 'Game Data Utility' Enter this and locate the GTA IV option. Highlight this and press triangle once, from the menu select Delete. This will delete the game's install information.

2) Delete the game's save files. To delete any save files you will need to do the following. Scroll along the cross media bar until you reach the 'Game' tab, now scroll up / down the list until you reach the 'Save Data Utility' Enter this and locate the GTA IV option. Highlight this and press triangle once, and from the context menu select Delete.

3) Disable your Internet connectivity for the PS3. To do this scroll along the cross media bar until you reach the 'Settings' tab, now scroll up / down the list until you reach the 'Network Settings'. Now scroll down to the Internet connection option and press x, now select the disable option. Once this has been done unplug the ethernet cable if you are connecting to the Internet if using this.

4) Disable the console's information board. To do this scroll along the cross media bar until you reach the 'Network' tab, now scroll up / down the list until you reach the 'Information Board', highlight this and press triangle. From the menu select 'Do not display' Press X to confirm this.

5) Disable Media Server functionality. Scroll to Settings, now scroll up / down to 'Network Settings' select Media Server connection. Once this has been done press triangle and change the option Disabled.

6) Delete all of the system's Internet cache. To do this scroll along the cross media bar until you reach the 'Network' tab, now scroll up / down the list until you reach the 'Internet Browser', highlight this and press X. Once you browser opens press the triangle button once, from the new menu highlight the 'Tools' option and press X. Scroll down the menu until you reach 'Delete Cookies' and press X. Confirm the files deletion. Repeat this for 'Delete Cache'.

7 ) Turn off the PS3 screen saver. Use the cross media bar to scroll to 'Settings', select 'Display Settings'. Now highlight 'Screensaver' and set this to 'Do not use'.

8 ) Once this has been done, manually restart you PS3 by holding down the power button for 5 seconds it will beep once and then shut down. Release the power button and re-press it and hold for about 5 seconds. The system will then boot and reset all display settings. You will be prompted to reset your display settings to how you require them.

9) Once restarted please try the game again, you will be prompted to reinstall.

Once the game has started please turn off the following features:

1) The game's auto-save. Press Start, Game, and locate the Auto-save option. Turn this off.

2) Turn off the game's flicker filter. Press Start, Display and locate the Flicker Filter option. Turn this off.

3) Turn off the controller vibration feature. Press Start, Controls and locate the vibration option. Turn this off.

I cut this from some forum board, I might add. 

Tags:   , ,
Categories:   Games
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Who is emirr

Saturday, 3 May 2008 00:21 by Myself

Hacker alias 3M1RR ("emirr?") seems to have found an exploit in blogengine.net.

I have not done much digging around the case but a quick google shows his many victims. I dare to guess it has something to do with hacking the web api. I will get more info tomorrow, now I need sleep.

This is my third encounter with a real hacker. The first was on one of my oldest sites --"back in the days"-- stenstugan.net (Russian hacker). Then my school shell account (kindof Russian hacker, he was from Belarus). Then this third bastard, who according to a youtube account with the same name, is of Turkish origin.

Just some curiosa.

Hitting my new book! Good night!

Tags:  
Categories:  
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

FTP Upload from SQL Server 2005

Friday, 28 March 2008 13:24 by Myself

The credit of this script goes to Nigel Rivett. I have merely added what I felt was missing and adjusted it to SQL 2005.

Change list:

  • Generates a random temporary script (allows for many concurrent executions)
  • Deletes the temporary script afterwards (we don't want to reveal the FTP credentials too easy)
  • The use of an in-memory-table instead of a temp table.
  • Friendlier output and return code validation.
  • I prefer to have these kind of stored procedures under my Tools schema.

Nothing fancy but rather fundamental.

   1: IF NOT EXISTS(SELECT SCHEMA_ID('Tools'))
   2:     EXEC('CREATE SCHEMA Tools') -- CREATE SCHEMA needs to be the first statement of a batch
   3:     
   4: IF EXISTS (select * from sysobjects where id = object_id(N'[Tools].[PutFile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
   5:     DROP PROCEDURE [Tools].[PutFile]
   6: GO
   7:  
   8: CREATE PROCEDURE [Tools].[PutFile]
   9: (
  10:     @FTPServer      nvarchar(128) ,
  11:     @FTPUser        nvarchar(128) ,
  12:     @FTPPWD         nvarchar(128) ,
  13:     @FTPPath        nvarchar(128) ,
  14:     @FTPFileName    nvarchar(128) ,
  15:  
  16:     @SourcePath     nvarchar(128) ,
  17:     @SourceFile     nvarchar(128) ,
  18:  
  19:     @WorkDir        nvarchar(128)
  20: )
  21: AS
  22:     SET NOCOUNT ON;
  23: /*
  24: exec [Tools].[PutFile]    
  25:         @FTPServer = 'myftp.com' ,
  26:         @FTPUser = 'usr' ,
  27:         @FTPPWD = 'pwd' ,
  28:         @FTPPath = '/Upload_Here/' ,
  29:         @FTPFileName = 'from_sql_2005.txt' ,
  30:         @SourcePath = 'c:\temp\' ,
  31:         @SourceFile = 'mytable.txt' ,
  32:         
  33:         @workdir = 'c:\temp\'
  34: */
  35:  
  36:     declare    @cmd varchar(1000)
  37:     declare @workfilename varchar(128)
  38:     DECLARE @returncode int
  39:     
  40:     /* We insert a 4 character random string to the temporary ftp script - Otherwise two concurrent calls would interfere w/ eachother */
  41:     select @workfilename = 'ftpcmd_{rand}.txt' 
  42:     SELECT @workfilename = REPLACE(@workfilename,'{rand}', LEFT(CAST(NEWID() AS nvarchar(max)),4))
  43:     
  44:     -- deal with special characters for echo commands
  45:     select @FTPServer = replace(replace(replace(@FTPServer, '|', '^|'),'<','^<'),'>','^>')
  46:     select @FTPUser = replace(replace(replace(@FTPUser, '|', '^|'),'<','^<'),'>','^>')
  47:     select @FTPPWD = replace(replace(replace(@FTPPWD, '|', '^|'),'<','^<'),'>','^>')
  48:     select @FTPPath = replace(replace(replace(@FTPPath, '|', '^|'),'<','^<'),'>','^>')
  49:     
  50:     select    @cmd = 'echo '                    + 'open ' + @FTPServer
  51:             + ' > ' + @workdir + @workfilename
  52:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  53:     select    @cmd = 'echo '                    + @FTPUser
  54:             + '>> ' + @workdir + @workfilename
  55:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  56:     select    @cmd = 'echo '                    + @FTPPWD
  57:             + '>> ' + @workdir + @workfilename
  58:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  59:     select    @cmd = 'echo '                    + 'put ' + @SourcePath + @SourceFile + ' ' + @FTPPath + @FTPFileName
  60:             + ' >> ' + @workdir + @workfilename
  61:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  62:     select    @cmd = 'echo '                    + 'quit'
  63:             + ' >> ' + @workdir + @workfilename
  64:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  65:     
  66:     select @cmd = 'ftp -s:' + @workdir + @workfilename
  67:     
  68:     DECLARE @result TABLE (id int identity(1,1), s varchar(1000))
  69:     insert @result
  70:     exec @returncode = master..xp_cmdshell @cmd
  71:     
  72:     IF(@returncode = 0)
  73:         INSERT @result SELECT 'FTP command successfully executed'
  74:     
  75:     select [output] = s from @result WHERE s IS NOT NULL 
  76:         AND s NOT LIKE 'quit'
  77:     
  78:     /* Remove the ftp cmd afterwards*/
  79:     select @cmd = 'delete ' + @workdir + @workfilename
  80:     exec master..xp_cmdshell @cmd, NO_OUTPUT
  81: go
  82:  

 

This was my first post using Live Writer. I've installed some useful plugins such as

And on the blogengine.net side

Tags:   ,
Categories:   Development | Sql Server 2005
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Painless backup on SQL 2005

Wednesday, 26 March 2008 10:27 by Myself

I found this great Backup and Maintenance script for SQL 2005 on Ola Hallengrens blog

I am no fan of Maintenance Plans in SQL Server. Even though maintenance isn't my job - I write databases - I couldn't help to be annoyed by all the backup jobs causing chaos in the Job Agent list. Every database had it's M.Plan and corresponding job. So I decided to find a better solution. One that I could feel comfortable with.

Moving the entire backup plan to this script will make it much more sustainable. I am going to test it this week.

Safari for Windows

Tuesday, 25 March 2008 16:17 by Myself

Apple has released the first stable version of Safari (3.1) for Windows. Perhaps it's not what a windows user should like, I mean, it's not proper etiquette. But it sure is cool! Cool

According to Apple it's supposed to be quicker than both ie and firefox and other sources told me that Safari performed the best acid2 test.

Check it out here

 

Safari
Tags:   ,
Categories:   Applications
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Firefox 3 Beta 3

Wednesday, 13 February 2008 14:05 by Myself

Beta 3 of firefox 3 was released today, and a exciting new look was introduced. The toolbar is very clean! Yet futuristic and appealing. Undecided

  My other favorite news in firefox 3 (but not necessarily introduced in beta 3)

  • Slim menu bar (means more browsing space)
  • Improved (rewritten) bookmark system which is integrated with rss subscriptions
  • Faster loading
  • The drop down of the address bar contains title and description of the page, very nice too!


Get it now at getfirefox.com 
Tags:   ,
Categories:   Applications
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

The ultimate notepad (classic blog topic)

Monday, 28 January 2008 14:59 by Myself

I proudly present the 10001:th entry about notepad replacements in windows!

My favorite is metapad - it might not be the fastest or the lightest nor does it have all the super cool features - But it is a good compromise of all categories. Try it!

To replace it in windows vista, I found a good guide on simonguest.com's blog. Here's a quick recap:

Start a cmd prompt as admin and write:
1: takeown /f {path_to_notepad}\notepad.exe
then
2: cacls {path_to_notepad}\notepad.exe /G {username}:F
for both c:\windows\system32\ and c:\windows\ because notepad.exe is located in both (as simonguest forgot to mension)
3: rename metapad.exe to notepad.exe and copy+replace to both locations (start with system32\)

Go download metapad from the coolest url ever: liquidninja.com!

Tags:   , , ,
Categories:   Applications
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Passwords for dummies

Tuesday, 15 January 2008 11:18 by Myself
There has been a lot of hacks recently (bilddagboken.se, efterfesten.com, aftonbladet.com). So there's a good point in using different passwords on every site if you want to minimize the risk. That was one of the stupid mistakes, but not the biggest, that the admin of efterfesten.com seems to have made. I feel no sympathy for these site admins that takes lightly on security. Let them be thaught a lesson! Cool

  A tip to these site admins: Mix your passwords and store them in a central and safe place, like KeePass Password Safe. Some features are 

  • Strong Security
  • Multiple User Keys
  • Portable and No Installation Required 
Tags:  
Categories:   Applications
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

A real router

Tuesday, 15 January 2008 10:05 by Myself

I've been using my server as a router for a while. Switching between Server 2008 and XP a few times, being unable to decide which of them best suits my need.

I can basically achieve the same functionality with XP as Server 2008. (NAT, DNS). To activate it on XP, I just type;

netsh routing ip nat install
netsh routing ip nat add interface "My Dsl modem" full
netsh routing ip nat add interface "Local Area Connection" private
netsh routing ip dnsproxy install

 

 And then I set my LAN clients to static IP's. The only problem was to route certain traffic to my clients, like the PS3 which needs a few ports for online play.  I tried to make a batch script to open the ports. I made it half way, opening some ports on my server but I couldn't find the syntax (if it's even possible through netsh) to route the port to a NAT client.

 

firewall add portopening TCP [port] [rule_name]

  My point is, I'm sick of this, a custom homebrew router should be linux based. I am ordering a D-Link Xtreme N™ Gigabit Router (DIR-655) today! It will fit perfect with my PS3 and I will configure it once no matter how many times I wipe my server OS. 

Tags:   , ,
Categories:   oggelito.com
Actions:   E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed
 
Software