Wednesday, March 26, 2014

PS1X + DareCup = Browser-based DameWare Remote Access

I've been developing a PowerShell-based website with software created by www.powershellserver.com.  The product is PowerShell ASP and is a combination of PowerShell, ASP, and HTML.  It's great for aggregating data from SharePoint, SCCM, PC's via RWMI, and various intranet sites and spreadsheets.  I recently pulled in the agency inventory and thought it'd be great when a customer calls in to pull up their PC number via username then click on a DameWare link.  This has been a problem as the website runs under the system account so any server-side calls stay within the system account and give GUI.  Today I found a gem on the Internet.  The little program is named DareCup.  Double-click on the installer and it asks where your DameWare Remote Control software is, copies the darecup.exe file to the folder, then writes two registry entries which add a Protocol Handler.  The handler works with both Internet Explorer and Chrome.  I had to manually go into the Chrome Protocol Handler section (even though there were no entries), close the menu, then it worked.  When writing code, simply place a <a href=rc://computername>DameWare</a> and the handler redirects the call to DameWare which opens the GUI.  You can even go so far as to enter your username and password plus RDP protocol if you wish.

Here's the article I was reading when I found the link:
http://community.spiceworks.com/how_to/show/1794-dameware-mini-remote-spiceworks-integration

and some instructions from the site.  The DareCup download also comes with instructions and a code sample.
rc:// -The DareCup URL Handler
#{ip_address} -variable from Spiceworks/Dynamic Troubleshooting Action Link (#{name} could also be used instead of #{ip_address})
username=YOUR_USERNAME -username for Dameware
password=YOUR_PASSWORD -password for Dameware
domain=YOUR_DOMAIN -domain for Dameware
Monitor=viewonly -starts Dameware in view only mode
Connectiontype=autoconnect -attempts to automatically connect when started
Closeondisconnect=autoclose -when disconnecting it closes Dameware

Here's an example of how I use this utility to open a DameWare connection via weblink:

<a title='Dameware' href='rc://targetcomputer>?domain=MyDomain&username=MyUserName&password=MyPassword&connectiontype=autoconnect&Closeondisconnect=autoclose&-a:1'><img style="margin:0px 0px 0px 5px;vertical-align:text-top;" src=/images/dw.png width=17></a>

Note that I've added a -a:1 to the end of the GET method.  Even though DareCup doesn't know what it means, it still accepts the variable and passes it to DameWare for processing.  The -a stands for Authentication and type 1 means authenticate via NT Challenge (Active Directory/Windows SAM).

To use:
* Download the DareCup zip package and extract.
* Using your admin account, install DareCup.  It will ask where your DameWare Remote software is located.
* When finished, your web browser will redirect RC:// calls to the DareCup application.  In Chrome, it'll pop up with an external Protocol prompt: