<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bohack &#187; CMD</title>
	<atom:link href="http://www.bohack.com/tag/cmd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bohack.com</link>
	<description>Check In and Tune Out!</description>
	<lastBuildDate>Sun, 08 Jan 2012 20:59:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Windows Server 2008 Replacement of ProxyCfg.exe</title>
		<link>http://www.bohack.com/2010/08/windows-server-2008-replacement-of-proxycfg-exe/</link>
		<comments>http://www.bohack.com/2010/08/windows-server-2008-replacement-of-proxycfg-exe/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 00:39:20 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[CMD]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=416</guid>
		<description><![CDATA[When setting up a secure server farm you always want to filter egress traffic. This means that all outbound traffic is blocked by default, including the web traffic from the servers. When surfing is required for drivers and downloads, this is usually handled by setting the proxy in the Internet Explorer options.  However if you want certain processes / services like Windows Update to automatically retrieve updates and wait for manual approval, the next time you login. You need to set a proxy server up and force the Local Machine to use it. The setting in the IE properties page is for the Current User only.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2010/08/windows-server-2008-replacement-of-proxycfg-exe/' addthis:title='Windows Server 2008 Replacement of ProxyCfg.exe ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When setting up a secure server farm you always want to filter egress traffic. This means that all outbound traffic is blocked by default, including the web traffic from the servers. When surfing is required for drivers and downloads, this is usually handled by setting the proxy in the Internet Explorer options.  However if you want certain processes / services like Windows Update to automatically retrieve updates and wait for manual approval, the next time you login. You need to set a proxy server up and force the Local Machine to use it. The setting in the IE properties page is for the Current User only.</p>
<p><span id="more-416"></span>In Windows XP and Windows 2003 this was done via the command proxycfg.exe. You would simply set and unset the &#8220;Local Machine&#8221; proxy with the commands:</p>
<pre>The old way to set the "Local Machine" proxy:

Proxycfg –p {proxy address:port} {bypass list}

Proxycfg -p "proxy.bohack.com:8180" "&lt;local&gt;;*.bohack.com"

The old way to unset it:

Proxycfg –d
</pre>
<p>It basically sets the registry value below, to the values you specify in with the proxycfg command.</p>
<pre>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\WinHttpSettings</pre>
<p>So what happened to the &#8220;proxycfg.exe&#8221; command? Starting in Vista, Windows Server 2008 and Windows 7 you will no longer find the proxycfg command. It has now been replaced with the &#8220;netsh&#8221; command. This command can be used either interactively by tying &#8220;netsh&#8221; and navigating the tree of commands or used in a one line command sequence, like shown below.</p>
<pre>The new way to set the "Local Machine" Proxy:

netsh winhttp set proxy {proxy address:port} {bypass list}

netsh winhttp set proxy "proxy.bohack.com:8180" "&lt;local&gt;;*.bohack.com"

The new way to unset it:

netsh winhttp reset proxy

Check the settings with:

netsh winhttp show proxy
</pre>
<p>The new commands change the same registry value above, the only thing that changed it the command to set and unset the Local Machine proxy. Theoretically you could export out the registry setting and import it onto another machine.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2010/08/windows-server-2008-replacement-of-proxycfg-exe/' addthis:title='Windows Server 2008 Replacement of ProxyCfg.exe ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2010/08/windows-server-2008-replacement-of-proxycfg-exe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mastering Permissions with icacls.exe Command thru the GUI</title>
		<link>http://www.bohack.com/2009/12/mastering-permissions-with-icacls-exe-command-thru-the-gui/</link>
		<comments>http://www.bohack.com/2009/12/mastering-permissions-with-icacls-exe-command-thru-the-gui/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 15:41:37 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[CMD]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=350</guid>
		<description><![CDATA[The key to mastering permissions at the command line in Vista and Windows Server 2008 Server is learning the icacls.exe command. With the introduction of Windows Vista, you can no longer select multiple items like folders and files and apply permissions to a group of objects.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/12/mastering-permissions-with-icacls-exe-command-thru-the-gui/' addthis:title='Mastering Permissions with icacls.exe Command thru the GUI ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>The key to mastering permissions at the command line in Vista and Windows Server 2008 Server is learning the icacls.exe command. With the introduction of Windows Vista, you can no longer select multiple items like folders and files and apply permissions to a group of objects. The recommended way is to use the command line and the icacls.exe command.</p>
<p><span id="more-350"></span><br />
The icacls.exe command was introduced in Windows 2003 Service Pack 2. It now comes installed by default in Windows Vista, Windows Server 2008 (R2) and Windows 7. So administrators will need to learn this command sooner or later. Recently I found the tool to be very flexible and I extensively documented the options. I mapped the different command line options to the GUI, for the network admins that need the GUI to understand how to use the command line.</p>
<p>The first point that should be made about icacls.exe is that it defaults to edit mode. The original cacls command defaults to replace mode. Next are the commands:</p>
<pre>/grant will grant user permissions or the add option in the GUI.
/remove will remove the user from the DACL and is equivalent to
 the remove option in the GUI.

Note: /remove:g will remove only grants for the user
      and /remove:d will remove only denys for the user.

/deny is equivalent to the deny column in the GUI
 and should always be used cautiously.
/setowner is a handy little command which allows you to change
 the ownership of a file or folder to another user;
 this is similar to the linux chown command.
/findsid which finds entries in a DACL for a specified SID or user.
/setintegritylevel is a bit out of the scope of this article
 and may be in a future article.</pre>
<p>The icacls command also has an /inheritance command which performs the same function as un-checking the “Include inheritable permission from this object’s parent” in the GUI. This of course presents you with the question of how to proceed; copy the permissions or remove all existing permissions. So the command line you can specify:</p>
<pre>/inheritance:e to enable same as a check box in the GUI.
/inheritance:d to disable and copy the permissions
 from the parent same as the GUI.
/inheritance:r to disable and remove the
 current permissions again same as the GUI.</pre>
<a href="http://www.bohack.com/wp-content/uploads/2009/12/icacls-gui.jpg"  rel="lightbox[350]"  class="lightbox"><img src="http://www.bohack.com/wp-content/uploads/photojar/cache/icacls-gui-150x150-1-img355.jpg" alt="Windows GUI mapped to icacls commands" title="icacls-gui" width="150" height="150" class="aligncenter size-thumbnail wp-image-355" /></a>
<p>The next thing to learn is how inheritance is propagated for permissions. When using either the /grant or /deny statement you will build the permissions as <em>/grant {user}:{inheritance}{permissions}</em> everything is encapsulated by parenthesis. The default in Windows when applying permissions in the GUI is “This folder, subfolders and files”, but to achieve the default at the command line you need to use <em>/grant {user}: (OI)(CI){permissions}</em> and the permissions should be encapsulated in parenthesis. The table below is to help you formulate your inheritance for permissions:</p>
<pre>This folder only
This folder, subfolders and files (OI)(CI)
This folder and subfolders (CI)
This folder and files (OI)
Subfolders and files only (OI)(CI)(NP)(IO)
Subfolders only (CI)(IO)
Files only (OI)(IO)</pre>
<p>The last thing to learn is the permissions. You can use macro permissions, which are also called simple permissions or you can use advanced permissions. The simple permissions are the permissions found in the first properties tab under security. The advanced permissions are when you select advanced and you get the full permissions list. So building on the permissions line from above; if we wanted to grant testuser on the folder test and apply modify permissions so all subfolders and files inherited the permissions. The line would be ‘<em>icacls test /grant testuser:(OI)(CI)(M)</em>’</p>
<pre>Simple Permissions

Full Control (F)
Modify (M)
Read &amp; Execute (RX)
List Folder Contents (X,RD,RA,REA,RC)
Read (R)
Write (W)

Advanced Permissions

Full Control (F)
Traverse folder / execute file (X)
List folder / read data (RD)
Read attributes (RA)
Read extended attributes (REA)
Create file / write data (WD)
Create folders / append data (AD)
Write attributes (WA)
Write extended attributes (WEA)
Delete subfolders and files (DC)
Delete (D)
Read permissions (RC)
Change permissions (WDAC)
Take ownership (WO)</pre>
<p>When you master this command you will be able to do anything with permissions from the command line. Including understanding the SDDL or Security Descriptor Definition Language; which Microsoft uses to create group policy permissions.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/12/mastering-permissions-with-icacls-exe-command-thru-the-gui/' addthis:title='Mastering Permissions with icacls.exe Command thru the GUI ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/12/mastering-permissions-with-icacls-exe-command-thru-the-gui/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Command Prompt Anywhere</title>
		<link>http://www.bohack.com/2008/12/command-prompt-anywhere/</link>
		<comments>http://www.bohack.com/2008/12/command-prompt-anywhere/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 19:06:01 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[CMD]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=165</guid>
		<description><![CDATA[Any day you can walk up to my workstation at work and find a command prompt open. Whether it is a Windows CMD prompt or a Linux Shell; I actually prefer it over the Windows GUI and over a KDE or Gnome on Linux. I can generally get more done in a few keystrokes then [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2008/12/command-prompt-anywhere/' addthis:title='Command Prompt Anywhere ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Any day you can walk up to my workstation at work and find a command prompt open. Whether it is a Windows CMD prompt or a Linux Shell; I actually prefer it over the Windows GUI and over a KDE or Gnome on Linux. I can generally get more done in a few keystrokes then mouse clicks, especially when you need to start a task and have a log of the outcome.</p>
<p><span id="more-165"></span>Some things the GUI is great for like exploring a file structure. Many times you are browsing the GUI and realize you need to drop to a command prompt to start a task. Rather than clicking &#8216;Start&#8217;, then &#8216;Run&#8217;, typing &#8216;CMD enter&#8217; and then changing directory, it would be nice to right click and drop to a CMD prompt from the Windows context menu.</p>
<a href="http://www.bohack.com/wp-content/uploads/2008/12/screenshot078.jpg"  rel="lightbox[165]"  class="lightbox"><img src="http://www.bohack.com/wp-content/uploads/2008/12/screenshot078.jpg" alt="Command Prompt Anywhere" title="Command Prompt Anywhere" width="300" height="300" class="alignnone size-medium wp-image-167" /></a>
<p>I have been using this little crafted registry hack for years now. There are two needs for a command prompt one is right clicking on a file  or other object and the other is right clicking on a folder. The &#8216;Command Prompt Anywhere.reg&#8217; below takes care of both instances. The first part edits the default context menu so that the &#8216;CommandPrompt&#8217; shows up for files and objects not defined as a folder. The second part edits the folder context menu so that &#8216;CommandPrompt&#8217; shows for folders.</p>
<p>There is one limitation It will not work for network locations, this is a limitation of using the &#8216;cd&#8217; command and can be changed using the &#8216;pushd&#8217; command. The &#8216;pushd&#8217; command will temporarily map the network location to the first drive letter available starting from &#8216;Z&#8217; and working backwards in the alphabet. However if the &#8216;cd&#8217; command in the scripts is replaced with &#8216;pushd&#8217; you will need to keep the network mappings tidy, by using either a &#8216;net use z: /d&#8217; or &#8216;popd&#8217; before you exit the prompt.</p>
<pre>
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\CommandPrompt]

[HKEY_CLASSES_ROOT\*\shell\CommandPrompt\Command]
@="cmd.exe /k cd \"%1/..\""

[HKEY_CLASSES_ROOT\Directory\shell]

[HKEY_CLASSES_ROOT\Directory\shell\CommandPrompt]

[HKEY_CLASSES_ROOT\Directory\shell\CommandPrompt\Command]
@="cmd.exe /k cd \"%1\""
</pre>
<p>To install just copy and paste it to a file called &#8216;Command Prompt Anywhere.reg&#8217;,Â  then double click it and answer &#8216;yes&#8217; to the warning.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2008/12/command-prompt-anywhere/' addthis:title='Command Prompt Anywhere ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2008/12/command-prompt-anywhere/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

