Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Securing Windows Remote Desktop

Just a quick list of pointers to help you secure RDP today...

For a while now, I've been using Windows Live Mesh to connect to my home PC's from remote locations. This method was really simple and didn't require any firewall changes on my router. Unfortunately SkyDrive, Live Mesh's successor, does not include this feature so I'll need to use RDP or another service such as LogMeIn.com. LogMeIn is a great service, so I'd recommend using this (even MS is recommending it!)

But for those of you that prefer/need to use RDP, here's a few tips for increasing security:

Change RDP TCP port (done in the registry)

Consider implementing an SSH tunnel

Update account password to strong as possible

rename admin account to non-standard name

disable all other accounts for RDP

If possible, restrict RDP client IP range in router or other firewall

Enable windows firewall for extra protection

Checklist After Configuring
Can other ips can connect?

Can accounts other than the desired one connect?

Further Reading
http://theillustratednetwork.mvps.org/Ssh/RemoteDesktopSSH.html

http://revision3.com/hak5/HackingRDP

Resetting a network adapter with Powershell

I recently moved to a new PC and there's something wrong with the network configuration. The hardware seems OK but every few hours Windows reports that there is no Internet connection. I haven't spent much time troubleshooting but it looks like the PC loses its IP lease and does not renew it, but that's mostly just a guess at this stage.

The Windows 7 Troubleshooter reports:

The Network Diagnostics Framework has completed the diagnosis phase of operation. The following repair option was offered:

Helper Class Name: AddressAcquisition

Root Cause: "Local Area Connection" doesn't have a valid IP configuration

Root Cause Guid: {245a9d66-ae9c-4518-a5b4-655752b0a5bd}

Repair option: Investigate router or broadband modem issues
If you're connected to a hotspot or domain network, contact the network administrator. Otherwise:
    1.  Unplug or turn off the device.
    2.  After all the lights on the device are off, wait at least 10 seconds.
    3.  Turn the device on or plug it back into the power outlet.
To restart a router or modem that has a built-in battery, press and quickly release the Reset button.

RepairGuid: {9513cc1c-4a26-4cb8-bf89-0a82129bd105}

Seconds required for repair: 63

Security context required for repair: 0

Interface: Local Area Connection ({419b3c06-e283-4a99-adaa-b66439dd064d})


Running the Troubleshooter does fix the issue. It appears that this tool resets the network adapter which forces a new IP to be allocated to the interface.

I've never had this type of issue with Ethernet on Windows before, although I have experienced unstable 802.11 connections on certain laptops.

I've also updated the Intel NIC driver to see if this would help - it didn't. Others do seem to have this issue also. Most people use the workaround of assigning a static IP to the adapter - this isn't an option for me in this environment.

Anyway, I need to remote into this PC so I can't have it sitting there with a non-working network connection!

So to get around this problem, I wrote a script in Powershell which I've scheduled in Task Scheduler to run every 10 minutes. The script will check if the network connection has Internet connectivity and, if not, will reset the network adapter. So the longest I'll have to wait to get on to the PC will be 10 minutes.

Here it is:

# Set up event log source
# redirect stderr to null since there's no simple way to check if the source already exists
(new-eventlog -logname Application -Source "Reset Network Adapter") 2> $null

$pingResponse = Get-WmiObject -Class Win32_PingStatus -Filter "Address='www.google.com.au'" -ComputerName . | Select-Object -Property Address,ResponseTime,StatusCode

if ($pingResponse.ResponseTime -eq $null) {
    Write-Host Network connection down. Resetting adapter.
    write-eventlog Application -source "Reset Network Adapter" -eventid 1 -message "Network connection down. Resetting adapter."

    # Assumes you have only one ethernet device in your PC. If you have more, use something like: '-and $_.Name like "*Intel*"'
    $adapter = Get-WmiObject -Class Win32_networkadapter | Where-Object { $_.AdapterType -eq "Ethernet 802.3" }
    $adapter.disable()
    $adapter.enable()
} else {
    Write-Host Network connection seems OK
    write-eventlog Application -source "Reset Network Adapter" -eventid 2 -message "Network connection seems OK"
}

Hope that helps someone!

Scheduling the Task

This is quite simple but I recommend creating a new user on your system to run the task. For the above script they need to be in the Local Admin group in order to create the event log.

Add an action with:

command: powershell
and 
arguments: -file path_to\reset-adapter.ps1

An Exercise for the Reader

You can trigger a Windows scheduled task based on an event. When the network fails there are a bunch of events that are generated by applications and the System. You could pick one that reliably represents this network issue and set up your scheduled task to only run when this event is detected. This is a nicer approach that polling every 10 minutes.

Some hints for finding appropriate events in the System Log:
  • Source: Time-Service, DNS Client Events

Resources

Testing exit code of Windows Batch file

Even though PowerShell is awesome, the old DOS Batch file is still a useful and commonly used tool. You will find Batch files powering crucial automated processes all over the globe.

Commonly you will run a sequence of commands and check each of them for successful completion. The usual way to do this is to check the errorlevel variable like so:

c:\mycommand.exe
if errorlevel 1 exit 1

(NOTE, you need to clear any environment variables called errorlevel because the Batch interpreter will return these instead of the built in variable if they are defined. Do this just like this: set errorlevel=)

Anyway, once you have checked each of your commands for errors, you will usually print out error messages and return your own error codes so that external programs calling your batch file will know what went wrong. You do this like so:

exit 2

Where 2 is an error code that means something specific to your script.

Testing these initially seems difficult because when you run the script it exits and you cannot check which error code was returned. There is a way to test these! Here it is:

cmd /k myscript.bat
echo %errorlevel%

Hope that helps - send me questions/comments below!

Giving a Windows directory a drive letter

Sometimes you need to test a program/script on your local machine that is expecting a certain drive, let's say X: drive. Your local machine may only have a C: drive, so what do you do?

You could reconfigure the script to use your C: drive but this is an unnecessary extra step. Instead you can create drive letters that map to Windows directories (folders) using the SUBST command.

It's easy, at your command line, type:

subst DRIVE_LETTER: PATH

For example:

subst X: C:\temp\testdata

You must not add a trailing slash to the directory or it will not work.

Once you're done, just add /D to the command plus drive letter, e.g.

subst X: /D
Hope this makes your life easier!

[Via Lifehacker -> via Codejacked]

A couple of useful tools for managing stored credentials in Windows Vista/7

While messing around with a problem with cached IE credntials today, I came across these Windows user management tools.

(put the commands into the "Run" box in the start menu)

Stored usernames and passwords:

Command: rundll32.exe keymgr.dll, KRShowKeyMgr

- in this tool you can see commonly stored credentials for websites, servers and programs. Some interesting things in here. TBH, not entirely sure what these are used for!
- this is also useful if you want to transfer all your credentials over to another computer.

User Accounts

Command: control userpasswords2
- this is a simplified version of the usual user manager
- under Advanced -> Passwords, you can get to the stored usernames tool mentioned above

Regular user manager
Command: lusrmgr

Slow right-click Windows context menus got you down?

Here's what to do:

Use the free application ShellExView from Nirsoft to find unnecessary context menu items and disable them. This can actually have a big effect on the noticeable performance of your menus. Psychologically, this can result in a much more enjoyable computer use experience.

1. Download the program
2. Start it up.
3. Sort by Type and scroll down to Context Menu
4. Look for the items in red first - they are non-Microsoft applications.
5. For each item you want to disable, press F7 or right-click and select Disable. This happens instantly so you can right click on a file or folder in Windows explorer and see the result. You can also disable MS items.

This tool works on any version of Windows from 98 up to Windows 7 64 bit.
Thanks to this blog post for the tip!

Don't forget to donate to NirSoft if you feel like it helped you.

If you need help, just ask in the comments!

How to delete files in Windows Vista

Sometimes it can seem impossible to delete a file/directory in Vista.
This is because of the way security is implemented.

The easiest way to get around this is to first make your account the owner of the file/directory in question. It will help if you have an Administrator account.

You can do this in the Windows file/folder properties but this is quite confusing, so try it in the command line.

Click on the start menu, and type cmd in the Search Box, then hit Enter.

In the command prompt type:

takeown /f [path to file/directory]

The /f switch means that we're taking ownership the specified file in the path.

Now you should see a message like:

SUCCESS: The file (or folder): "[path]" now owned by user "[computer name]\[user name]".

The next step is to give yourself permission to delete the file. This is achieved with:

cacls [path] /G [your user name]:F

/G means we are granting permissions to a user.
And the F means Full Control

Now you should be allowed to delete it. So just do so with:

del [path]

That's it!

"The network path was not found" error on Win XP sp2

The problem
You are unable to connect to any network resource (network shares, printer, etc) on a Windows XP machine, from a Win XP client.

A solution (there could be several causes)
  • On the target machine (the one you're trying to connect to) open up Services, under Administrative Tools in the Start Menu.
  • Scroll down to the Computer Browser service.
  • If it is Disabled or set to Manual, set it to Automatic.
  • Then start it. It may stop immediately again, but this is OK.
  • At this point try to connect to the target machine.
If it still doesn't work, you can try the following:
  • open up Network Connections, under Control Panel.
  • Right click on your network adapter and click on Properties.
  • Click on Internet Protocol (TCP/IP), then click on Properties.
  • Click on Advanced, and click on the WINS tab.
  • Even if it is set to Default, set the radio button to Enable NetBIOS over TCP/IP.
  • Press OK on each screen until everything's closed.
  • Go back to the client machine and try again.
  • You should be able to connect!
If it still doesn't work:
  • Go back to the Services window and find the service named Routing and Remote Access.
  • Double-click on it, set it to Manual, and stop it.
  • Close Services and try to connect from your client machine again.
For further info on this issue, you may like to consult the following recommended books: Home Networking For Dummies (For Dummies (Computer/Tech)), Microsoft Windows XP Networking Inside Out, or Windows XP Home Networking.

If this helped you, or if you found another solution to this common and frustrating problem, please leave a comment to help others!

p.s. See here for a possible Windows 2000 solution.

If you're tearing your hair out with the SSIS 'Failed to acquire connection...' error...

.. try setting the TransactionOption property on the package to NotSupported.
Your problem could be that MSDTC is either not running, incorrectly configured, or being blocked by a firewall.

This problem is common when migrating a package, which you've been working on a local dev machine, to a staging or production server. Servers commonly have tighter security restrictions than desktops or perhaps the admin hasn't even enabled MSDTC.

If you really need transactions then you'll have to delve into this issue deeper!

Here's some links to help you:
http://blogs.conchango.com/jamiethomson/archive/2005/11/02/2339.aspx
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=146&messageid=266032

etc..

Tags

windows (10) microsoft (9) .net (6) google chrome (5) windows 7 (5) asp.net (4) google (4) google browser (4) development (3) javascript (3) mssql (3) rss (3) sql server (3) wordpress (3) automation (2) blogging (2) css (2) database (2) firefox (2) get all wordpress images (2) gmail (2) google docs (2) intel (2) internet explorer (2) linux (2) linux commands (2) microsoft word (2) mysql (2) netsh (2) network issue (2) proxy (2) seo tips (2) shell (2) sun (2) tfs (2) videos (2) wget (2) windows networking (2) windows vista (2) winhttp (2) .net 3.5 (1) .net 4.5 (1) .net async ctp3 (1) .net framework 4.0 (1) 404 (1) JungleDisk (1) access (1) active directory (1) addons (1) adobe acrobat (1) adobe dlm (1) adobe reader (1) adp (1) adsense (1) adtoll (1) adwords (1) amazon (1) antivirus (1) asp.net 4.0 (1) authentication (1) back links (1) backlinks (1) bacula (1) bash (1) batch files (1) blogger (1) box (1) browser exploits (1) category rss (1) cell phone (1) cell phone comparison (1) charting (1) cheap cell phones (1) cheap laptop upgrades (1) checkout (1) chrome (1) chrome.manifest (1) cloud (1) cloud hosting (1) cloud vps (1) code (1) color chart (1) colour chart (1) conditional formatting (1) config (1) configuration (1) context menu (1) copy (1) corrupt (1) credentials (1) cross-reference (1) database scripts (1) dba scripts (1) debian (1) decrypt (1) delete file windows vista (1) delete files (1) dell (1) dell laptop (1) dell studio (1) dell studio 1537 (1) dhcp (1) directory size (1) div (1) dns (1) document properties (1) dotnet (1) download (1) dreamhost (1) dreamhost coupon (1) dreamhost promo (1) dreamhost promo code (1) drive letter (1) drivers (1) duplicate content (1) editpad pro (1) encrypt (1) encryption (1) error (1) error code (1) excel (1) exception (1) external hard drive (1) facebook (1) faviconize (1) feeds (1) firefox 3 rc1 (1) firefox 3.1 (1) firefox addons (1) firefox tabs (1) firewall (1) firewall script (1) fix (1) fix .net framework (1) foreign keys (1) gmail 2.0 (1) gmail error (1) google chrome 2.0 (1) google chrome dev (1) google chrome exploit (1) google reader (1) google reader tags (1) gtdinbox (1) hard drive (1) hex color (1) hex colour (1) htaccess (1) html (1) html 5 (1) iis6 (1) installation (1) ipod touch (1) ipod touch 2g (1) ipod touch freeze (1) ipod touch magnet case (1) ipod touch magnet case problem (1) ipod touch problem (1) iterator pattern (1) itunes (1) java (1) joomla (1) jquery (1) laptop (1) laptop upgrade (1) laptops (1) latex (1) leeching (1) like button (1) link checker (1) linkbacks (1) linq (1) linqdatasource (1) lost password (1) making money online (1) map drive (1) mega cheap phones (1) microsoft excel (1) microsoft signature (1) microsoft store (1) microsoft web deploy (1) microsoft windows (1) microsoft word 2007 (1) minimize firefox tabs (1) mozy (1) ms word (1) msdeploy (1) msdtc (1) nant (1) netstumbler (1) network path not found (1) network path was not found (1) network problem (1) networking (1) new movies (1) nintendo (1) nirsoft (1) nocheckbrowser (1) number (1) odf (1) odt (1) online backups (1) open source browser (1) openoffice (1) oracle (1) oracle client (1) photoshop (1) phpmyadmin (1) podcast (1) powershell (1) pr checker (1) productivity (1) proxy server (1) proxycfg (1) putty (1) recover (1) registry (1) reinstall windows 7 (1) remote desktop (1) remove (1) repair (1) reset joomla admin password (1) rewrite (1) rsa (1) sandy bridge laptop (1) seagate momentus xt (1) seo tools (1) sequence (1) server monitoring (1) sftp (1) social networks (1) softlayer (1) soulseek (1) spreadsheet (1) spreadsheet formula (1) sql (1) sql scripts (1) sql server management studio (1) sqlclient (1) ssh (1) ssis (1) ssl (1) ssms (1) subst (1) tabmixplus (1) telstra (1) text editor (1) trust (1) unlock cell phone (1) unlock mobile phone (1) upgrade laptop hard drive (1) user management (1) vb.net (1) video download (1) virtual server (1) visual studio (1) vodafone (1) vodafone australia (1) vps (1) vps.net (1) wd external drive (1) web deploy (1) web dev (1) web development (1) web hosting (1) web security (1) webdev (1) webmail (1) webmaster tips (1) western digital (1) wifi networks (1) wii (1) win7 (1) windows 7 backup (1) windows 7 gadgets (1) windows 8 (1) windows 8 antivirus (1) windows error (1) windows live (1) windows live essentials (1) windows live toolbar (1) windows tips (1) windows web development (1) windows xp (1) winxp (1) wireless networks (1) word tips (1) wordpress 2.7 (1) wordpress plugin (1) wp super cache (1) yield (1) youtube download (1) youtube playlist download (1)