Damon Cortesi's blog

Musings of an entrepreneur.

It’s a Wonderful Life

| Comments

Just finished up It’s A Wonderful Life - such a nice movie. I’ve probably watched it every year for the past four years and I still like it. Who knows how many times my Mother has seen it, but she still watches it too.

I wonder how many people still watch that ‘ol movie…

No Way - Maniac Mansion Deluxe!

| Comments

via [Wired]: It seems some fan of the old game Maniac Mansion (I played the Nintendo version) have created a remake, Maniac Mansion Deluxe - an exact remake with the exception of a new MIDI soundtrack and 256-color graphics.

/me plays Maniac Mansion Deluxe on Chritmas Eve, hehehe.

Different Privileges in Visual Studio Debug Mode

| Comments

I’m mucking around with process tokens in C++ lately (stealing tokens and whatnot…) and was having an odd problem when I would run my application in Visual Studio versus when I would run it from a command prompt.

In the case of running the program from Visual Studio, I could use the OpenProcess function fine, but OpenProcessToken would fail with access denied.

In the case of running it from a command prompt, OpenProcess would fail with access denied. I figured it must have something to do with certain privileges debug mode enables in the application.

Using Process Explorer, I fired up the application from both cases and compared the security attributes. Exactly the same. Despite that, I was still convinced that it had something to do with privilege levels.

After a few failed searches, I decided to dig into why OpenProcessToken was failing in the first place and try to figure out the Visual Studio problem at a later point. It was then that I stumbled on this gem. I had almost ignored it because I missed the reply at the top of the page that reads

Make sure you’re not impersonating while calling OpenProcessToken.
Oh man…I know I’m calling ImpersonateSelf, but could that really be what’s causing the difference in Visual Studio? After adding a RevertToSelf after properly adjusting my token privileges, the application ran the same in both Visual Studio and the command prompt. smack

Now I just need to figure out why I can’t use OpenProcessToken on those few applications like CSRSS and other users’ processes. It’s obviously possible as both Task Manager and Process Explorer are able to get usernames associated with processes, but I’m having the most difficult time figuring out how they do that.

Microsoft Needs to Do a Better Job With Documentation

| Comments

I just discovered today that there is a /random parameter that you can pass to the net user command.

C:>net user test /add /random Password for test is: gLsaP_QH

The command completed successfully.

Well isn’t that convenient! Now answer me this - why is there absolutely no mention of this in the “net help user” documentation? Please, Microsoft, proper documentation would make our lives so much easier.

Note that I’ve spent almost an entire day of experimenting with the previously undocumented NtQuerySystemInformation API, so I may be mildly bitter. grin

I should note that a search on Google for “net user * /random” nets only 122 results.

Monitor Network Shares Using Windows Scripting

| Comments

Somebody asked a question on microsoft.public.scripting.wsh recently about monitoring network shares using Windows scripting. I wasn’t sure if this was possible (i.e. using event sinks or something of the like), so I started Googling around to see what I could find. After several unsuccessful searches, I finally came across something useful - Running a Script Based on an Event [WMI].

Although it was a little complex, it got me on the right track regarding monitoring events and the Win32 class I would need to focus on, Win32_ServerConnection. Once I knew what I was looking for, it was only a matter of time before I found some sample code to monitor connections to network shares.

The end result, for those of you at home, if that link above dissappears, is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<div class='bogus-wrapper'><notextile><figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class=''><span class='line'><font color="#000080"><b>Set </b></font>services <font color="#808080">= </font><font color="#000080"><b>GetObject</b></font><font color="#808080">(</font><font color="#800000">"WinMgmts:"</font><font color="#808080">)
</span><span class='line'>
</span><span class='line'></font>services<font color="#808080">.</font>security_<font color="#808080">.</font>privileges<font color="#808080">.</font>addasstring <font color="#800000">"sedebugprivilege"
</span><span class='line'>
</span><span class='line'></font><font color="#000080"><b>Set </b></font>sink <font color="#808080">= </font>WScript<font color="#808080">.</font><font color="#000080"><b>CreateObject</b></font><font color="#808080">(</font><font color="#800000">"WbemScripting.SWbemSink"</font><font color="#808080">,</font><font color="#800000">"SINK_"</font><font color="#808080">)
</span><span class='line'>
</span><span class='line'></font>services<font color="#808080">.</font>ExecNotificationQueryAsync sink<font color="#808080">, </font>_
</span><span class='line'>  <font color="#800000">"select * from __InstanceCreationEvent " </font><font color="#808080">& </font>_
</span><span class='line'>    <font color="#800000">"WITHIN 1 where Targetinstance ISA 'Win32_ServerConnection'"
</span><span class='line'></font><font color="#000080"><b>MsgBox </b></font><font color="#800000">"Wait for an event. " </font><font color="#808080">& </font>VBCRLF <font color="#808080">& </font><font color="#800000">"Click OK to stop watching for events!"
</span><span class='line'>
</span><span class='line'></font><font color="#000080"><b>Sub </b></font>SINK_OnObjectReady<font color="#808080">(</font>objWbemObject<font color="#808080">, </font>objAsyncContext<font color="#808080">)
</span><span class='line'>  </font>Wscript<font color="#808080">.</font>Echo <font color="#800000">" Share Name: " </font><font color="#808080">& </font>_
</span><span class='line'>    objWbemObject<font color="#808080">.</font>TargetInstance<font color="#808080">.</font>ShareName
</span><span class='line'>  Wscript<font color="#808080">.</font>Echo <font color="#800000">" Computer : " </font><font color="#808080">& </font>_
</span><span class='line'>    objWbemObject<font color="#808080">.</font>TargetInstance<font color="#808080">.</font>ComputerName
</span><span class='line'>  Wscript<font color="#808080">.</font>Echo <font color="#800000">" User : " </font><font color="#808080">& </font>_
</span><span class='line'>    objWbemObject<font color="#808080">.</font>TargetInstance<font color="#808080">.</font>UserName
</span><span class='line'>  Wscript<font color="#808080">.</font>Echo
</span><span class='line'><font color="#000080"><b>End Sub
</span><span class='line'></b></font></span></code></pre></td></tr></table></div></figure></notextile></div>

This will print out a line with the share name, and originating IP address and username any time a connection is made to a share. I learn more about Windows Scripting Host every day.

Google Suggest…been There, Done That

| Comments

Scoble blogs about Google’s new Google Suggest. That is awesome!

PHP.net did something similar to this over a year ago with their search page.

I tore their javascript apart in hopes of using it for some of my own functionality and that is some impressive coding. It took me a good few hours to even begin to understand the design behind their search page. I’ll have to check out Google’s (if possible) and see if it is similar at all.

Impressive CG

| Comments

I am constantly amazed with the technology of today. I just met a very impressive digital woman named Kaya. That’s both scary and amazing at the same time.

via growabrain