<?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>brunerd &#187; Scripting</title>
	<atom:link href="http://www.brunerd.com/blog/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brunerd.com/blog</link>
	<description>curly haired mac nerd</description>
	<lastBuildDate>Tue, 27 Dec 2011 04:35:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Make Safari find substring matches by default</title>
		<link>http://www.brunerd.com/blog/2011/08/10/make-safari-find-substring-matches-by-default/</link>
		<comments>http://www.brunerd.com/blog/2011/08/10/make-safari-find-substring-matches-by-default/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 18:22:59 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=402</guid>
		<description><![CDATA[So, I thought I&#8217;d tip ol&#8217; Pierre at betalogue to an apparent bug that Safari doesn&#8217;t find substrings, only words that begin with the search string! But then his astute readers pointed out that Safari 5.1 has changed the behaviour &#8230; <a href="http://www.brunerd.com/blog/2011/08/10/make-safari-find-substring-matches-by-default/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, I thought I&#8217;d <a href="http://www.betalogue.com/2011/08/09/safari51-substrings/" target="_blank">tip</a> ol&#8217; Pierre at betalogue to an apparent bug that Safari doesn&#8217;t find substrings, only words that begin with the search string! But then his astute readers pointed out that Safari 5.1 has changed the behaviour of the Find window, if you just look close enough *blush*</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/Safari-5.1-Search.png" target="_blank"><img class="aligncenter" title="Safari 5.1 Search" src="http://www.brunerd.com/blog/wp-content/uploads/Safari-5.1-Search.png" alt="" width="322" height="65" /></a></p>
<p>Now by default in Safari 5.1, when you hit Command-F and type in a word, Safari will match words that &#8220;Start with&#8221; your search item, clicking the magnifying glass, presents you with the option to search for words that &#8220;Contain&#8221; your search phrase (this was the default search behaviour in Safari pre-5.1), and in fact clicking the magnifying glass used to step through matches. Who knew!? I&#8217;m a (Shift)/Command-G man myself.</p>
<p>Now how could we change this behaviour back for a few hundred users who are used to the way Safari has been functioning before Apple so <em>elegantly</em> altered it? Here we go!</p>
<p>Preference domain: com.apple.Safari<br />
Key Name: <code>FindOnPageMatchesWordStartsOnly</code><br />
Values: Boolean, TRUE equals &#8220;Start With&#8221; and FALSE equals &#8220;Contains&#8221;.</p>
<p>It is a per-user preference, if the key is not present Safari defaults to &#8220;Start With&#8221; in a search. Writing the pref to the higher level /Library/Preferences/com.apple.Safari.plist will affect all users who don&#8217;t already have the key set, otherwise Safari will defer to the user&#8217;s prefs (and it can then be assumed the user is aware of the change since they clicked on the magnifying glass and altered the setting).</p>
<p>Here&#8217;s the defaults commands for Terminal to set Safari&#8217;s Find back to &#8220;Contains&#8221;:<br />
<strong>All Users (who don&#8217;t have it set in their prefs)</strong><br />
<code>defaults write /Library/Preferences/com.apple.Safari FindOnPageMatchesWordStartsOnly -bool FALSE</code><br />
<strong>Current User</strong><br />
<code>defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool FALSE</code></p>
<p>There you go that&#8217;ll get things back the way they were, make sure it&#8217;s all on one line, the theme seems to like to wrap code, but a copy/paste does not include the newline.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/08/10/make-safari-find-substring-matches-by-default/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Restore previous Safari version from .SafariArchive.tar.gz</title>
		<link>http://www.brunerd.com/blog/2011/07/21/restore-previous-safari-version-from-safariarchive-tar-gz/</link>
		<comments>http://www.brunerd.com/blog/2011/07/21/restore-previous-safari-version-from-safariarchive-tar-gz/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 20:39:57 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=394</guid>
		<description><![CDATA[Did that new Safari update break something? Want your old version back? Simple. Thanks to Apple&#8217;s prescient yet secretive engineers, there&#8217;s a way. Let me show you. When Safari does an upgrade it saves the previous version in this location: &#8230; <a href="http://www.brunerd.com/blog/2011/07/21/restore-previous-safari-version-from-safariarchive-tar-gz/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Did that new Safari update break something? Want your old version back?<br />
Simple. Thanks to Apple&#8217;s prescient yet secretive engineers, there&#8217;s a way.<br />
Let me show you.</p>
<p>When Safari does an upgrade it saves the previous version in this location:<br />
<code>/Library/Application\ Support/Apple/.SafariArchive.tar.gz</code></p>
<p>To restore we just need to tell tar to expand the archive to the root folder:<br />
<code>sudo tar -xvf /Library/Application\ Support/Apple/.SafariArchive.tar.gz -C /</code></p>
<p>To be complete, delete the receipt from /var/db/receipts, in this case it is Safari 5.1<br />
<code>sudo rm -rf /private/var/db/receipts/com.apple.pkg.Safari51SnowLeopard.*</code></p>
<p>Reboot. (since we&#8217;ve just replaced a whole bunch of public and private frameworks the OS uses)</p>
<p>Done.<br />
(Whew. This will fix the early Safari 5.1 adopters at work who now can&#8217;t use our Java based timesheet app since upgrading!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/07/21/restore-previous-safari-version-from-safariarchive-tar-gz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>myXProtectStatus</title>
		<link>http://www.brunerd.com/blog/2011/06/16/myxprotectstatus/</link>
		<comments>http://www.brunerd.com/blog/2011/06/16/myxprotectstatus/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 17:43:26 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=385</guid>
		<description><![CDATA[myXProtectStatus &#8211; A drop down status menulet for XProtect, showing date, version, and threats protected against. Written in bash, and wrapped with Platypus, it is informational only, so don&#8217;t ask me to add some menu item to do something, it just reports. &#8230; <a href="http://www.brunerd.com/blog/2011/06/16/myxprotectstatus/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://brunerd.com/software/myXProtectStatus.zip">myXProtectStatus</a> &#8211; A drop down status menulet for XProtect, showing date, version, and threats protected against. Written in bash, and wrapped with Platypus, it is informational only, so don&#8217;t ask me to add some menu item to <em>do</em> something, it just reports. However I did add the Command Line and GUI ways to update XProtect in the output, so it&#8217;s of some use for that. When run, it&#8217;ll reside in your menu bar and call a script inside itself each time it runs. Tuck it away somewhere, add it to your loginitems. Check it every once and a while&#8230;</p>
<p>Screenshot of myXProtectStatus:</p>
<h3><img title="myXProtect" src="http://www.brunerd.com/blog/wp-content/uploads/myXProtect.png" alt="" width="349" height="471" /></h3>
<p>Other notes: I pipe the output of the threat list though /usr/bin/uniq, because while Hell.RTS has three different signatures it retains the same name in each and it seemed redundant to list all of them out! So all recurring names will be reduced to one entry.</p>
<p>The menu bar icon: it&#8217;s an X with a grey picket fence around it, I made it tiny&#8230; then realized I need an icon for the App too rather than Platypus&#8217; so I sized it up, it&#8217;s fugly, but you&#8217;ll never see it! <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bonus: When run as root, it will show the auto-update on/off status, which can only be determined on the command line by root.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/06/16/myxprotectstatus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Safe Downloads List Info Widget</title>
		<link>http://www.brunerd.com/blog/2011/06/03/safe-downloads-widget/</link>
		<comments>http://www.brunerd.com/blog/2011/06/03/safe-downloads-widget/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 17:41:00 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=343</guid>
		<description><![CDATA[UPDATE: The AUTOUPDATE code only works as root and so is not useful in the Dashboard environment! This has been removed from the widget. So I slapped together a widget for the Safe Downloads commands I post at OSXHints: Safe &#8230; <a href="http://www.brunerd.com/blog/2011/06/03/safe-downloads-widget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>UPDATE: The AUTOUPDATE code only works as root and so is not useful in the Dashboard environment! This has been removed from the widget.</p>
<p>So I slapped together a widget for the Safe Downloads commands I post at <a href="http://hints.macworld.com/article.php?story=20110602091032338">OSXHints</a>:</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-381" title="Safe Downloads Info" src="http://www.brunerd.com/blog/wp-content/uploads/Safe-Downloads-Info.png" alt="" width="346" height="120" /></p>
<p style="text-align: center;"><a href="http://www.brunerd.com/software/Safe-Downloads-Info.zip">Safe Downloads Info Widget</a></p>
<p>Nothing glamorous just the facts and the following code is how it gets it&#8217;s values:</p>
<p><code>defaults read /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta LastModification<br />
defaults read /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta Version</code></p>
<p>The auto updates status took a bit more massaging:</p>
<p><code>eval $(sudo defaults read /private/var/db/launchd.db/com.apple.launchd/overrides com.apple.xprotectupdater | sed 's/ //g')<br />
if [ ${Disabled:=0} -eq 0 ]; then<br />
echo ON<br />
else<br />
echo OFF<br />
fi</code></p>
<p>All apologies to Dashboard coding perfectionists but the calls for the widget are synchronous, and reading up on Dashboard coding best practices, Apple says a shipping widget should only use asynchronous calls for info&#8230; oh well it works well enough for me! <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Perhaps I&#8217;ll go back and throw in extra lines of code for asynchronous handlers when I can, if my widget freezes up any other widgets you can simply restart Dashboard by killing to Dock process from Activity Monitor.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/06/03/safe-downloads-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More App Store tips for admins</title>
		<link>http://www.brunerd.com/blog/2011/01/25/more-app-store-tips-for-admins/</link>
		<comments>http://www.brunerd.com/blog/2011/01/25/more-app-store-tips-for-admins/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 17:43:32 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=268</guid>
		<description><![CDATA[Continuing the tech ramble about how to keep the App Store from your users&#8230; So, I figured out the two ways the App Store icon is added to the dock: 1. Existing users on an upgraded system are affected by &#8230; <a href="http://www.brunerd.com/blog/2011/01/25/more-app-store-tips-for-admins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Continuing the tech ramble about how to keep the App Store from your users&#8230;</p>
<p>So, I figured out the two ways the App Store icon is added to the dock:</p>
<p>1. <strong>Existing</strong> users on an upgraded system are affected by this file: <strong>/Library/Preferences/com.apple.dockfixup</strong></p>
<p>Looking at the add-app key inside contains the answer:</p>
<p><code> </code></p>
<p><code> </code></p>
<p><code></p>
<div id="_mcePaste">&lt;key&gt;add-app&lt;/key&gt;</div>
<div id="_mcePaste">&lt;array&gt;</div>
<div id="_mcePaste" style="padding-left: 30px;">&lt;dict&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;key&gt;path&lt;/key&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;string&gt;/Applications/App Store.app&lt;/string&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;key&gt;after&lt;/key&gt;</div>
<div id="_mcePaste" style="padding-left: 60px;">&lt;string&gt;begin&lt;/string&gt;</div>
<div id="_mcePaste" style="padding-left: 30px;">&lt;/dict&gt;</div>
<div id="_mcePaste">&lt;/array&gt;</div>
<p></code></p>
<p>We can rid ourselves of  this behavior with defaults:</p>
<p><code>defaults delete /Library/Preferences/com.apple.dockfixup add-app</code></p>
<p>However, if you try to use a loginhook to remove the icon, it will not take effect unitl the second login, sine the loginhook runs <em>before</em> Apple&#8217;s dockfixup is applied.</p>
<p>The solution to a user never seeing it (and avoiding calls about it) is to use a daemon that runs at system startup and deletes the entry in the plist before it is ever used.</p>
<p>Save as /Library/LaunchDaemon/com.brunerd.dockfixer.plist (or whatever you wish):</p>
<p><code> </code></p>
<p><code> </code></p>
<p><code></p>
<p style="margin: 0.0px 0.0px 13.0px 0.0px; line-height: 19.0px; font: 13.0px Courier;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;<br />
&lt;plist version="1.0"&gt;<br />
&lt;dict&gt;<br />
<span style="white-space: pre;"> </span>&lt;key&gt;Label&lt;/key&gt;<br />
<span style="white-space: pre;"> </span>&lt;string&gt;com.sts.dockfixup&lt;/string&gt;<br />
<span style="white-space: pre;"> </span>&lt;key&gt;ProgramArguments&lt;/key&gt;<br />
<span style="white-space: pre;"> </span>&lt;array&gt;<br />
<span style="white-space: pre;"> </span>&lt;string&gt;defaults&lt;/string&gt;<br />
<span style="white-space: pre;"> </span>&lt;string&gt;delete&lt;/string&gt;<br />
<span style="white-space: pre;"> </span>&lt;string&gt;/Library/Preferences/com.apple.dockfixup&lt;/string&gt;<br />
<span style="white-space: pre;"> </span>&lt;string&gt;add-app&lt;/string&gt;<br />
<span style="white-space: pre;"> </span>&lt;/array&gt;<br />
<span style="white-space: pre;"> </span>&lt;key&gt;RunAtLoad&lt;/key&gt;<br />
<span style="white-space: pre;"> </span>&lt;true/&gt;<br />
&lt;/dict&gt;<br />
&lt;/plist&gt;</p>
<p></code></p>
<p>You could call another script, check for add-app&#8217;s presence, but having this run everytime, insures that despite OS updates and reversions of files your user will never have App Store added to their Docks.</p>
<p>2. Suppressing App Store in new user accounts is affected by Dock.app&#8217;s default.plist:<br />
<code><strong>/System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist</strong></code></p>
<p>But just deleting this and not com.apple.fixup.plist will not do what you want since fixup will still run, <strong>you must delete both</strong>. Altering that is the perfect job for <a href="http://brunerd.com/software/RemoveItemFromDock/RemoveItemFromDock.dmg">removeitemfromdock</a>&#8230; if only it worked with a supplied path&#8230; now it does! So after installing and <a href="http://brunerd.com/software/RemoveItemFromDock/RemoveItemFromDock.dmg">downloading</a> you can run this command to alter the default dock:</p>
<p><code>sudo /sbin/removeitemfromdock -f /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist /Applications/App\ Store.app/</code></p>
<p>You could make this another Daemon or just have the daemon call an external script, your choice, I can&#8217;t do <em>all</em> the work for you <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/01/25/more-app-store-tips-for-admins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>App Store tips and tricks for sysadmins</title>
		<link>http://www.brunerd.com/blog/2011/01/14/app-store-tips-and-tricks-for-sysadmins/</link>
		<comments>http://www.brunerd.com/blog/2011/01/14/app-store-tips-and-tricks-for-sysadmins/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 18:33:55 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=244</guid>
		<description><![CDATA[App Store Tips, Tricks, and Hacks for the SysAdmin App Store, oh, App Store, like all Apple products you are made first for consumers and in time maybe you will be ready for corporate deployment, but for now, here&#8217;s some &#8230; <a href="http://www.brunerd.com/blog/2011/01/14/app-store-tips-and-tricks-for-sysadmins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<div>
<h1>App Store Tips, Tricks, and Hacks for the SysAdmin</h1>
<p>App Store, oh, App Store, like all Apple products you are made first for consumers and in time maybe you will be ready for corporate deployment, but for now, here&#8217;s some tips for the Mac IT worker needs to wrangle this beast.</p>
<p>Firstly, the App Store, if you&#8217;ve noticed, requires admin rights to download and install apps. Not just because it installs to /Applications (it could be ~/Applications if it wanted to&#8230;) But most likely due to the new location of the receipts folder in /var/db/receipts. Up until version 10.6 it was /Library/Receipts and this would have made it possible to use the <a href="http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFileSystem/Articles/Domains.html" target="_blank">domain system</a> that was the simple genius of OS X, where things can live in /System/Library, /Library, or ~/Library and when the system couldn&#8217;t find a pref or support file in one domain it would look in the next. Fonts are a great example of this in action, why didn&#8217;t they think it was a good idea for receipts is anyone&#8217;s guess. But since there is no way to make an analogous folder structure of /var/db/receipts in a user&#8217;s home folder, much less have the system recognize there are receipts there, the App store is not &#8220;Standard User&#8221; compatible.</p>
<h4>Disabling Execution and hiding the App Store with Unix Permissions:</h4>
<p><code>#hide it<br />
sudo chflags hidden /Applications/App\ Store.app/</code></p>
<p><code>#keep it from executing for anyone other than root (since it is ownership is root:wheel)<br />
sudo chmod o-x /Applications/App\ Store.app/Contents/MacOS/App\ Store</code></p>
<p><code>#to let admin users execute, next change group ownership of executable<br />
sudo chgrp admin /Applications/App\ Store.app/Contents/MacOS/App\ Store</code></p>
<p><code> </code><code>#OR keep anyone from executing it<br />
sudo chmod ugo-x /Applications/App\ Store.app/Contents/MacOS/App\ Store<br />
</code><br />
Keeping the icon from populating the Dock is more troublesome, since Apple has changed this from 10.5, previous versions, it was a matter of altering /System/Library/User\ Template/English.lproj/Library/Preferences/com.apple.dock.plist but this no longer exists. I am searching for where this information is pulled&#8230; but in the meantime you could use a utility like <a href="http://www.brunerd.com/software/RemoveItemFromDock/RemoveItemFromDock.dmg">RemoveItemFromDock</a> to run for a user when they log in (note: a new user will not have a com.apple.dock.plist file until their first login, this makes it tricky for login scripts on first login&#8230;) I had a good lead in /Library/Preferences/com.apple.dockfixup.plist but removing the add-app entry that contains the path to the App Store did not help&#8230; wah wah.</p>
<p>Well, so you hidden the App Store, restricted it running, but <strong>what can your sneaky users do</strong>?</p>
<p>They can buy an App Store app on their home computer and then simply copy it to their work laptop. The app will prompt them to authorize it with their AppleID, boom, done, no problem for a Standard User. However, they will not get updates on the computer, since there is no receipt of its installation, this would need to be done manually. User bringing in paid apps to a work computer creates a quandary for admins who run app inventory on computers (especially if it&#8217;s for license compliance)! From my attempts at pruning and tinkering with the Parental controls MCX values in the user&#8217;s records there didn&#8217;t  seem to be a way to wildcard the white or blacklist, however it is promising that there is a boolean key call appStore that shows up. But for now enabling &#8220;Limit Applications&#8221; setting involves explicit approval for EVERY app they want to run that&#8217;s not on the whitelist, and personally I don&#8217;t care if you want to run <a href="http://www.aelius.com/primateplunge/" target="_blank">Primate Plunge</a> to waste time during conference calls &#8211; you and I will probably be saner for it. <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bottomline MCX doesn&#8217;t seem to have a straightforward way to deal with this now that doesn&#8217;t involve more admin overhead using Parental Controls.</p>
<p>Perhaps though, you don&#8217;t care what your user intalls from the App Store but you care enough that they are still Standard Users, well here&#8217;s the hack and slash way to enable them to use the app store&#8230;</p>
<h4>How to Allow Standard Users to Run the App Store*</h4>
<p><strong>*Disclaimer: !!!WARNING!!! Security settings are changed with this action!!!! HACK AT YOUR OWN RISK !!!!!</strong></p>
<p>#Make the App store an SUID binary so it runs as root *</p>
<p><code>sudo chmod +s /Applications/App\ Store.app/Contents/MacOS/App\ Store</code></p>
<p>#Change rights in /etc/authorization to allow system.privilege.setugid_appkit right by anyone* **</p>
<p><code>sudo cp /etc/authorization /etc/authorization.saved<br />
sudo cp /etc/authorization /etc/authorization.plist<br />
sudo defaults write /etc/authorization rights -dict-add system.privilege.setugid_appkit '&lt;dict&gt;&lt;key&gt;rule&lt;/key&gt;&lt;string&gt;allow&lt;/string&gt;&lt;/dict&gt;'<br />
sudo plutil -convert xml1 /etc/authorization.plist<br />
sudo sudo chmod go+r /etc/authorization.plist<br />
sudo mv /etc/authorization.plist /etc/authorization</code></p>
<p>There you go, your standard users can now install App Store apps.</p>
<p>*Disclaimer: !!!WARNING!!! Security settings are changed with this action!!!! HACK AT YOUR OWN RISK !!!!!</p>
<p>** When you Google this, you&#8217;ll find this is the same solution I found for using Flip4Mac with Compressor as a standard user. I just love reusable code <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I hope you learned something and even better I hope you might have some insight to add that I&#8217;ve missed, please send in your comments, thanks!</p>
<h4>Putting it all back the way it was before we started messing around</h4>
<p><code>sudo chmod u=rwx,go=rx /Applications/App\ Store.app/Contents/MacOS/App\ Store<br />
sudo chown root:wheel  /Applications/App\ Store.app/Contents/MacOS/App\ Store<br />
sudo chflags nohidden /Applications/App\ Store.app/<br />
mv /etc/authorization.saved /etc/authorization</code></p>
<p>Update: My removeitemfromdock script seems to have been thrown by a loop by changes to the dock plist, just like I had to work around Dashboard when it was itroduced to the Dock in a new way. Update to come&#8230;</p>
<p>Update-2: <a href="http://www.brunerd.com/software/RemoveItemFromDock/RemoveItemFromDock.dmg">removeitemfromdock</a> now works like a charm, my Dashboard hack was taking for granted that Dashboard is not always at position 0 after the Finder, so when App Store snuck in behind, it was getting skipped, now there are some robust kludges to deal with Dashboard&#8217;s non standard dock entry</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2011/01/14/app-store-tips-and-tricks-for-sysadmins/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tearing apart OpinionSpy</title>
		<link>http://www.brunerd.com/blog/2010/06/03/tearing-apart-opinionspy/</link>
		<comments>http://www.brunerd.com/blog/2010/06/03/tearing-apart-opinionspy/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 19:34:08 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=188</guid>
		<description><![CDATA[Updated: I&#8217;ve linked text files of string dumps to the binaries thoughout the article, I suppose not everyone wants to install and run the code to find out themselves! Another OS X malware media darling is out there, but it&#8217;s &#8230; <a href="http://www.brunerd.com/blog/2010/06/03/tearing-apart-opinionspy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>Updated: I&#8217;ve linked text files of string dumps to the binaries thoughout the article, I suppose not everyone wants to install and run the code to find out themselves! <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </em></p>
<p>Another OS X malware <a href="http://www.google.com/search?client=safari&amp;rls=en&amp;q=OpinionSpy&amp;oe=UTF-8&amp;um=1&amp;ie=UTF-8&amp;tbo=u&amp;tbs=nws:1&amp;source=og&amp;sa=N&amp;hl=en&amp;tab=wn" target="_blank">media darling</a> is out there, but it&#8217;s not the DNS changing kind that <a href="http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/" target="_blank">RSPlug-F</a> was. Rather this one has a <strong>lot</strong> more code in it, active code that is watching keystrokes, monitoring AIM, MSN, Yahoo, and iChat messengers and more.</p>
<p>So I found a <a href="http://www.brunerd.com/blog/wp-content/uploads/poinstaller.zip">sample</a> (this is the actual installer careful, folks) in the MishInc FLV To MP3 converter. Which is just a <a href="http://en.wikipedia.org/wiki/JAR_(file_format)" target="_blank">.jar</a> file, put .zip at the end and you can see the guts when expanded. However, it&#8217;s a self extracting installer using iZPack so it&#8217;s easier just to run it and let it unpack. Here&#8217;s some screenshots:</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/1.png"><img class="alignnone size-thumbnail wp-image-189" title="MishInc MP3 Install Screen 1" src="http://www.brunerd.com/blog/wp-content/uploads/1-150x150.png" alt="" width="150" height="150" /></a></p>
<p>Nothing much in there</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/2.png"><img class="alignnone size-medium wp-image-191" title="Premiere Opinion Accept/Disagree" src="http://www.brunerd.com/blog/wp-content/uploads/2-300x233.png" alt="" width="300" height="233" /></a></p>
<p>Jackpot on the 2nd screen, here&#8217;s the goods. Note, if you click I disagree, the software is not installed! Not <em>too</em> mal. Here&#8217;s the text from <a href="http://www.voicefive.com/About.aspx" target="_blank">VoiceFive</a>&#8216;s agreement:</p>
<blockquote><p>In order to provide this free download of MiMAC FLV To Mp3 Converter, PremierOpinion software, provided by VoiceFive, Inc., is included in this download. This software allows millions of participants in an online market research community to voice their opinions by <strong>allowing their online browsing and purchasing behavior to be monitored, collected</strong>, and once <strong>anonymized</strong>, used to create market reports, materials and other forms of analysis that may be shared with our clients to help our clients understand Internet trends and patterns and other market research purposes. The information which is monitored and collected includes internet usage information, basic demographic information, certain hardware, software, computer configuration and application usage information about the computer on which you install PremierOpinion.</p>
<p>We may use the<strong> information that we monitor, such as name and address</strong>, to better understand your household demographics; for example, we may combine the information that you provide us with additional information from consumer data brokers and other data sources in accordance with our privacy policy. We make <strong>commercially viable efforts</strong> to automatically filter confidential personally identifiable information and to purge our databases of such information about our panelists when inadvertently collected.</p>
<p>By clicking I Agree, you acknowledge that you are 18 years of age or older, an authorized user of this computer, and that you have read, agreed to, and have obtained the consent to the terms and conditions of the Privacy Statement and User License Agreement from anyone who will be using the computer on which you install this application.</p></blockquote>
<p>Does anyone else find it odd that they say your info is anonymized, but then go on to use an example of information they monitor is name and address?! But not worry, commercially viable efforts will be used to filter that out. Does that mean if it&#8217;s too expensive they won&#8217;t bother doing a really good job? Nonetheless for this installer, if you say I Disagree you are able to continue to install the MP3 converter without PremierOpinion installing.</p>
<p>But let&#8217;s say: <em>I agree</em> for the heck of it <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First it drops two files in <code>/private/tmp</code>: <code><a href="http://www.brunerd.com/blog/wp-content/uploads/script.sh.txt" target="_self">script.sh</a></code> which simply makes the other file, <code><a href="http://www.brunerd.com/blog/wp-content/uploads/poinstallerstrings.txt">poinstaller</a></code>, executable. If you are connected to the internet it then downloads two folders: <code>installtmp</code> and <code>tapinstaller</code>, both folders have the exact same binary called <code><a href="http://www.brunerd.com/blog/wp-content/uploads/PremierOpinionstrings.txt">PremierOpinion</a>(496KB)</code>, <code>installtmp</code> has a different sized <code>poinstaller</code> binary and <code>tapinstaller</code> contains <code><a href="http://www.brunerd.com/blog/wp-content/uploads/upgrade.xml_.txt" target="_self">upgrade.xml</a></code>, which contains a link to a file called <code><a href="http://www.brunerd.com/blog/wp-content/uploads/rule14.xml_.txt">rule14.xml</a></code>, found on a server at <code>post.securestudies.com</code>. Downloading <a href="http://post.securestudies.com/config/packages/pm/rule14.xml">rule14.xml</a> from them you get a link to the latest <a href="https://post.securestudies.com/config/packages/pm/PremierOpinion.zip">PremierOpinion.zip</a> and the version numbers of the expected support libraries and essential files.</p>
<p><code><a href="http://www.brunerd.com/blog/wp-content/uploads/poinstallerstrings.txt">pointsaller</a></code> has some Applescript to open the survey window in Safari and things like getting &#8220;campaign ids&#8221;, doing shell scripts with admin privileges, references to MacSniffer (a TCP packet sniffer), and more. Also while looking at the strings of poinstaller you&#8217;ll find reference not only to <code>post.securestudies.com</code> found but also <code>it.kingroutecn.com</code> which has the same <code>rule14.xml</code> but instead of <code>PremierOpinion</code> you get <code>PermissionResearch</code>. Doing some digging, it can be discovered that <a href="1http://www.voicefive.com/About.aspx" target="_blank">VoiceFive</a>, <a href="https://www.permissionresearch.com/Benefits.aspx" target="_blank">Permission Research</a> (which has many <em><a href="https://www.permissionresearch.com/ScreensaversDescription.aspx" target="_blank">screensavers</a></em> to download), and <a href="http://www.premieropinion.com/Home.aspx" target="_blank">Premier Opinion</a> are all in the same network block as <a href="http://news.google.com/news/search?pz=1&amp;cf=all&amp;ned=us&amp;hl=en&amp;q=ComScore">ComScore</a>, a multi-headed hydra of <a href="http://comscore.com/About_comScore/comScore_History" target="_blank">consumer buying</a> insight.</p>
<p>Now back to the Chinese server (which is not used to download the payload, perhaps, only in China?) digging <code>it.kingroutecn.com</code> gives you <code>218.108.8.85</code>, doing a reverse lookup gives  <code>hidden-master.hzman.net</code>, doing a reverse lookup gives you <code>127.0.0.1</code> that is you!? Whois on <code>it.kingroutecn.com</code> and <code>hidden-master.hzman.net</code> will point to <a href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=30.278739,120.158243&amp;sll=37.0625,-95.677068&amp;sspn=56.375007,79.453125&amp;ie=UTF8&amp;ll=30.27916,120.157456&amp;spn=0.007607,0.009699&amp;t=h&amp;z=17" target="_blank">Hangzhou, China</a>, a very big city just southwest of Shanghai (it looks smoggy in Google Maps). The question is why are their two similar packages being served from the US and China? And why is the <a href="http://it.kingroutecn.com:8081/oss/PermissionResearch.zip">Chinese version</a> newer (2.3.0.69 vs. 2.2.0.59)?</p>
<p>Anyway, Woodward and Bernstein aside, during all this unpacking of files in <code>/private/tmp</code> an <a href="http://www.brunerd.com/blog/wp-content/uploads/auth.png" target="_self">authentication window</a> asking for system.privelege.admin, that is to say, it wants root privileges. If you say yes, you&#8217;ll get a launchd daemon running as root installed to <code>/Library/LaunchDaemons/<a href="http://www.brunerd.com/blog/wp-content/uploads/PremierOpinion.plist_.txt">PremierOpinion.plist</a></code>, it&#8217;s an on-demand daemon that will respawn the <code>PremierOpinion</code> process if you try killing it in Activity Monitor. Respawning calls the <code>RunPremierOpinion.sh</code> script from <code>/Application/PremierOpinion</code> folder, it checks to see if you have Access for Assistive Devices enabled this is essential to logging your keystrokes. It does this by simply touching <code>/private/var/db/.AccessibilityAPIEnabled</code>, which can only be done by root, but it&#8217;s already running as that no prob! What&#8217;s weird about this file is that when you turn on Access for Assistive Devices via the GUI in System Preferences it creates the file with the single character &#8216;a&#8217; but OS X will still activate the service if the file is created  and is 0 bytes. After installing a Safari window will pop up asking you who uses the computer, the ages of the folks using it, and other tidbits, you can see <a href="http://www.premieropinion.com/Home.aspx" target="_blank">here</a>. When this app upgrades itself you will find a folder at <code>/private/tmp/autoupgrade</code> which has the same contents of <code>/Applications/PremierOpinion</code>.</p>
<p>So <code>/Applications/PremierOpinion</code> has quite a few things inside, libraries, scripts, and an Uninstaller (?!), and <code>PremierOpinion.app</code>. Inside the app is some Code Signing, the <a href="http://www.brunerd.com/blog/wp-content/uploads/PremierOpinionstrings1.txt">binary</a> (a much bigger 3.6MB version), and in Resources it contains <code>survey.nib, systemtray.nib and InjectCode.app</code>, which inside has <a href="http://github.com/rentzsch/mach_star" target="_blank">code</a> from Jonathan Rentzsch used for mach code injection*, taken from Growl&#8217;s 1.2 source code and recompiled by user huangxianghua as seen in the string: <code>/Volumes/10.5/Users/huangxianghua/Downloads/Growl-1.2-src/external_dependencies/mach_star/mach_inject_bundle/mach_inject_bundle</code></p>
<p>Further and further down the rabbit hole, but let&#8217;s just run the Uninstaller. It deletes the folder in Applications but the process remains as well as the LaunchDaemon and all the files in <code>/private/tmp</code>, however on reboot the process is indeed not running, <code>/private/tmp</code> is cleaned out, but the LaunchDaemon and Assistive Access remains on.</p>
<p>So here&#8217;s an uninstall script of my own (disconnect all network conections first, in case it is logging keystrokes, it might grab your password):<br />
<code><br />
sudo launchctl unload -w /Library/LaunchDaemons/PremierOpinion.plist<br />
sudo rm /private/tmp/poinstaller<br />
sudo rm /private/tmp/script.sh<br />
sudo rm -rf /private/tmp/installtmp<br />
sudo rm -rf /private/tmp/autoupgrade<br />
sudo rm -rf /private/tmp/tapinstaller<br />
sudo rm -rf /Applications/PremierOpinion<br />
sudo rm /private/var/db/.AccessibilityAPIEnabled</code></p>
<p>That should do it.</p>
<p>For extra insight, try running the PremierOpinion or PermissionResearch binary from the command line as root, there is all sorts of info to be found when it writes to stdout, such as when it starts a service port 8254: <code>2010-06-03 15:59:06.175 PermissionResearch[1658:60f] Starting server on port 8254</code> and, surf around a little, it&#8217;ll  report on the YouTube videos you are watching and other things it deems interesting.</p>
<p>Extra extra credit run a <a href="http://www.brunerd.com/blog/wp-content/uploads/Sample-of-PermissionResearch.txt" target="_blank">Sample</a> on it from Activity monitor and see what it&#8217;s doing: FileInventoryTask::MainTask(void*), file inventory eh, that&#8217;s why it&#8217;s eating up 30% of my CPU!</p>
<p>Hmmm, enough rabbit hole adventures for today, comments are welcome.</p>
<p>Oh yes, and  PowerPC  folks don&#8217;t worry, they didn&#8217;t compile for PPC <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>*Update:</p>
<p>To go on further about the injection aka <a href="http://www.google.com/search?client=safari&amp;rls=en&amp;q=method+swizzling&amp;ie=UTF-8&amp;oe=UTF-8" target="_blank">Method swizzling</a> code. This is where you have your code respond to a message call instead of the original code, the power in this is that you can get in the middle of the internal calls and do what you will with their data but then pass them on to the original method. So they probably are swizzling methods in Safari or perhaps at the network layer so they can see what you are downloading, watching, etc. Combined with packet sniffer &#8216;all your data are belong to them&#8217;. However please take note that these the reason this app can do this is because you&#8217;ve given them the keys to the castle by authenticating it as root, the technologies it&#8217;s leveraging aren&#8217;t inherently nefarious, rather fundamental and and essential to system operation, if root can&#8217;t do it then who can? This is where either it falls on the user or the OS needs to be better about protecting the user from themselves, perhaps the OS could sandbox downloaded apps with very restrictive settings, alerting you when it attempts something privileged, although this can desensitize a user quickly to clicking Agree. Nonetheless this is a defining conundrum of this century. The power of personal computers is being subverted for the nefarious gain of others and we need to defend against it, the era of curated computing might be ushered in because of this. We&#8217;ve seen it so many times, when good things get used for bad purposes, there&#8217;s a sea change. <a href="http://www.youtube.com/watch?v=ijPE7fe4XTg" target="_blank">Crises precipitates change.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2010/06/03/tearing-apart-opinionspy/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Make Acrobat Pro 9 for Mac shut the hell up!</title>
		<link>http://www.brunerd.com/blog/2010/02/05/make-acrobat-pro-9-for-mac-shut-the-hell-up/</link>
		<comments>http://www.brunerd.com/blog/2010/02/05/make-acrobat-pro-9-for-mac-shut-the-hell-up/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 17:52:58 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Packages]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=165</guid>
		<description><![CDATA[So, if you deploy Acrobat Pro to a corporate environment you already know what an aggravating experience it is to try and deploy updates to Adobe products. Silent install? Sure. Silent Update? No. Standard Mac .pkg? No. So you figure &#8230; <a href="http://www.brunerd.com/blog/2010/02/05/make-acrobat-pro-9-for-mac-shut-the-hell-up/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, if you deploy Acrobat Pro to a corporate environment you already know what an aggravating experience it is to try and deploy updates to Adobe products. Silent install? Sure. Silent Update? No. Standard Mac .pkg? No.</p>
<p>So you figure out all the files with loggen, Tracker, fseventer, or whatever your tool, then build your own package with Iceberg. Great. Then you find your &#8220;standard&#8221; users without admin privileges are getting bothered by Adobe&#8217;s SelfHeal BS.</p>
<p>Few things going on here that I&#8217;ll try and explain, the code formatting should be copy paste-able check it in a text editor, but all line breaks should be preserved.</p>
<p>Make sure you copy in the new Acrobat Internet-Plugin if the user is using that:<br />
<code>if [ -d "/Library/Internet Plug-Ins/AdobePDFViewer.plugin" ]; then<br />
rm -rf "/Library/Internet Plug-Ins/AdobePDFViewer.plugin";<br />
cp -R "/Applications/Adobe Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/SelfHealFiles/Library/Internet Plug-Ins/AdobePDFViewer.plugin" "/Library/Internet Plug-Ins/";<br />
fi</code></p>
<p>These next keys really make it complain if it can&#8217;t find them, and yes even if you don&#8217;t use the plugin it looks for WebBrowserUsePath, so make sure it&#8217;s there, and  NoViewerSelfHealNeeded gets a new date put after it for every release! Wow neato, a fun easter egg hunt, thanks Adobe!<br />
<code>defaults write /Library/Preferences/com.adobe.acrobat.90.sh "NoViewerSelfHealNeeded Dec 21 2009" -bool TRUE<br />
defaults write /Library/Preferences/com.adobe.acrobat.pdfviewer WebBrowserUsePath -string "file://localhost/Applications/Adobe%20Acrobat%209%20Pro/Adobe%20Acrobat%20Pro.app/"<br />
defaults write /Library/Preferences/com.adobe.acrobat.pdfviewer AdobePDFDriver -string "file://localhost/Applications/Adobe%20Acrobat%209%20Pro/Adobe%20Acrobat%20Pro.app/"</code></p>
<p>Now is the truly ridiculous part: if those files and keys aren&#8217;t found Acrobat ask for an <strong>administrator</strong> password and then proceed to write them in current users ~/Library/Preferences! What your users don&#8217;t know is they can click Cancel a couple times and it will still write them out, but your they&#8217;ve already called you to remote in and authenticate them &#8211; you lose! Why Adobe?! <strong>WHY</strong>!?! Asking for an admin password when you&#8217;ll just write it to ~/Library/Preferences?</p>
<p>PDF Printer &#8211; Here&#8217;s the files you need:<code><br />
/Library/Printers/PPDs/Contents/Resources/en.lproj/ADPDF9.PPD<br />
/Library/Printers/PPD Plugins/AdobePDFPDE900.plugin<br />
/usr/libexec/cups/backend/pdf900</code><br />
They are all found in:<code>/Applications/Adobe Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/SelfHealFiles/AdobePDFPrinter/</code></p>
<p>After you&#8217;ve copied them to their places, you can run Adobe install script:<br />
<code>/Applications/Adobe\ Acrobat\ 9\ Pro/Adobe\ Acrobat\ Pro.app/Contents/MacOS/SelfHealFiles/AdobePDFPrinter/cupshup.pl</code></p>
<p>I also figured this out in lpadmin too:<br />
<code>lpadmin -p AdobePDF9 -E -P /Library/Printers/PPDs/Contents/Resources/en.lproj/ADPDF9.PPD -v pdf900://distiller/ -D "Adobe PDF 9.0"</code></p>
<p>Even if you&#8217;ve copied in the PPD, the PDE plugin, the cups backend, and setup the printer, it&#8217;ll still think its damaged because you don&#8217;t have the PPD in Korean, Japanese, and two type of Chinese! So, must use PlistBuddy to correct this (because <code>defaults</code> is tricky to use when a dictionary is nested in an array &#8211; WHY Adobe?!)</p>
<p>Quiet the printer &#8220;repair&#8221;:<br />
<code>/usr/libexec/PlistBuddy -c "set :0:IsInstalledKey NO" /Library/Application\ Support/Adobe/Acrobat/SHExpectedMissingFileTypes.plist</code><br />
For Tiger users the path is: <code>/Library/Receipts/iTunesX.pkg/Contents/Resources/PlistBuddy</code></p>
<p>It&#8217;s almost shut the hell up, but the Adobe Updater might decide to pop-up and urge your user to call you up to run updates, so shut it up you got to jump through some hoops, its an &#8220;XML&#8221; file Adobe style so defaults won&#8217;t work on it, nor will plistbuddy, that and it&#8217;s a per user setting, so they must run it once to make the file, then you can change it:<code><br />
cat ~/Library/Application\ Support/Adobe/Updater6/AdobeUpdaterPrefs.dat | sed 's/1\&lt;\/AutoCheck\&gt;/0\&lt;\/AutoCheck\&gt;/' &gt; ~/Library/Application\ Support/Adobe/Updater6/AdobeUpdaterPrefs.new; mv ~/Library/Application\ Support/Adobe/Updater6/AdobeUpdaterPrefs.new ~/Library/Application\ Support/Adobe/Updater6/AdobeUpdaterPrefs.dat</code></p>
<p>Yes, Adobe has a <a href="http://kb2.adobe.com/cps/404/kb404813.html">document</a> for this but it seems only to remove the ability to check for updates within the app?!</p>
<p><code> </code></p>
<p>Trivia: You might want to copy  in the new AcroEFGPro90SelfHeal.xml file, although running &#8220;repair&#8221; from Acrobat will copy in the new file and for some odd Adobe reason, the self heal inside the app uses Mac line endings but when magically moved to <code>/Library/Application Support/</code>, it has Unix line endings changing the size by 2282 bytes (and also the place of a key as well?). This was a read herring in my research.<br />
<code>cp -f /Applications/Adobe\ Acrobat\ 9\ Pro/Adobe\ Acrobat\ Pro.app/Contents/MacOS/AcroEFGPro90SelfHeal.xml /Library/Application\ Support/Adobe/Acrobat/AcroEFGPro90SelfHeal.xml</code></p>
<p>Adobe: CS5 had better <strong>not</strong> use InstallerVISE, iNosso, bindiff, Java, XML, or whatever convoluted processes you are clinging to, just use the dang pkg format that Apple has provided &#8211; sheesh. Is this overwrought complex system supporting &#8220;make-work&#8221; jobs for programmers?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2010/02/05/make-acrobat-pro-9-for-mac-shut-the-hell-up/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tearing Apart OSX/RSPlug-F</title>
		<link>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/</link>
		<comments>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 19:51:39 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Packages]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=70</guid>
		<description><![CDATA[OK&#8230; I might be a bit late to the party (and Conficker is grabbing all the headlines) but there were some interesting things I found looking at the  headline grabbing trojan OSX/RSPlug-F. Thanks to the effervescent Graham Cluley for his &#8230; <a href="http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>OK&#8230; I might be a bit late to the party (and Conficker is grabbing all the headlines) but there were some interesting things I found looking at the  headline grabbing trojan <a href="http://www.sophos.com/security/blog/2009/03/3710.html" target="_blank">OSX/RSPlug-F</a>. Thanks to the effervescent Graham Cluley for his <a href="http://www.sophos.com/blogs/gc/g/2009/03/25/apple-mac-malware-caught-camera/" target="_blank">witty post</a> with video demonstration of OSX/RSPlug-F being detected. It&#8217;s what started this investigation.</p>
<p>So, being the curious guy I am I decided to download the very same file Graham did in his demo. While, hdtvxvid.org had since fixed their hijacked page, luckily the status bar had a readable URL that with some squinting I was able to decipher it&#8230; So I downloaded the sucker, you can too!</p>
<p>Live Code: <a href="http://plumpals.com/download/654a635065413d3df111c253/HDTVPlayerv3.5.exe" target="_blank">OSX/RSPlug-F trojan</a></p>
<p>And what else can I say but: I&#8217;ll be darned if I can get the thing to <strong>work</strong>! Actually I do get it to work, but due to some coding errors out of the box, it&#8217;s a dud.</p>
<p>So let&#8217;s start the dissection:</p>
<p>The URL downloads HDTVPlayerv3.5.dmg, inside is contained install.pkg, which if you&#8217;re using Safari on a Mac and have the damnable default of &#8220;Open &#8216;Safe&#8217; files after Downloading&#8221; it&#8217;ll go right to the installer. Which let me note <strong>Open &#8220;Safe&#8221; Files after downloading </strong>is the<strong> stupidest</strong> thing to happen to browsers since Active-X. The air quotes around &#8220;Safe&#8221; do not help, Apple, it&#8217;s a sly wink and a nod that <strong>no file type is totally safe</strong> but *shrug* whatcha gonna do? I&#8217;ll tell you what: <strong>don&#8217;t make it a dang default</strong>!</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/firefox-rsplug-cached-before-clicking-save.jpg"><img class="alignnone size-full wp-image-86" title="firefox-rsplug-cached-before-clicking-save" src="http://www.brunerd.com/blog/wp-content/uploads/firefox-rsplug-cached-before-clicking-save.jpg" alt="firefox-rsplug-cached-before-clicking-save" width="550" height="316" /></a></p>
<p><strong>Firefox</strong> is not off the hook either, let me bring up the poisonous Firefox convenience: &#8220;predownloading&#8221;. Did everyone notice how the virus alert for Graham pops up before he clicks save? How Firefox initiates downloads immediately to <a href="http://www.brunerd.com/blog/wp-content/uploads/firefoxcache-pre_downloading.jpg" target="_blank">cache</a> and upon the user clicking Save it copies it to the destination or if the click Cancel it stays there. I think Firefox&#8217;s behaviour is ridiculous, yes it might make me happy when I download some ginormous game demo and come back hours later having forgotten to click Save and am pleasantly surprised that &#8220;hey it&#8217;s already here!&#8221;, but otherwise let me decide what and when something goes on my hard drive.</p>
<p>Anyway&#8230; let&#8217;s look at an Installer window the average user won&#8217;t look at: Show Files</p>
<p>./AdobeFlash<br />
./Mozillaplug.plugin<br />
./Mozillaplug.plugin/Contents<br />
./Mozillaplug.plugin/Contents/Info.plist<br />
./Mozillaplug.plugin/Contents/MacOS<br />
./Mozillaplug.plugin/Contents/MacOS/VerifiedDownloadPlugin<br />
./Mozillaplug.plugin/Contents/Resources<br />
./Mozillaplug.plugin/Contents/Resources/VerifiedDownloadPlugin.rsrc<br />
./Mozillaplug.plugin/Contents/version.plist</p>
<p>First couple of suspect thing is a single flat file called AdobeFlash and then Mozillaplug.plugin, which is really just the <a href="http://unsanity.org/archives/mac_os_x/reminder_verifi.php" target="_blank">mysterious</a> VerifiedDownloadPlugin. No mention of Cinema eh?</p>
<p>Take a gander in <strong>Info.plist of install.pkg</strong> to see where it goes:<br />
IFPkgFlagDefaultLocation <em>/Library/Internet Plug-Ins/<br />
</em></p>
<p>So then, why would it need root privileges for an admin writable folder, eh?<br />
<a href="http://www.brunerd.com/blog/wp-content/uploads/redflag.png"><img class="alignnone size-full wp-image-84" title="redflag" src="http://www.brunerd.com/blog/wp-content/uploads/redflag.png" alt="redflag" width="514" height="407" /></a><br />
<strong>IFPkgFlagAuthorizationAction </strong><em>RootAuthorization</em>, for those following along in the Info.plist<br />
Bonus: <strong>CFBundleGetInfoString</strong> = <em>who cares<br />
<span style="font-style: normal;">Double Secret Bonus:<br />
Resource/en.lproj/Description.plist <strong>IFPkgDescriptionDescription</strong><em> = shutdafuckup</em></span></em></p>
<p>Strangely when you look in both the logs created by Installer.app in /var/log/installer.log:<br />
Leopard it says: <code>"<strong>admin</strong> auth received to install"<br />
</code>Tiger says: <code>"<strong>Administrator</strong> authorization granted."<br />
</code>I don&#8217;t know why you wouldn&#8217;t want the logs to clearly state root privileges were given, but there you have it, it doesn&#8217;t.</p>
<p>So what does it do with the root privileges? Hmmm? Let&#8217;s look in the preinstall/preupgrade <a href="http://www.brunerd.com/blog/wp-content/uploads/osx-rsplug-f_preinstall.txt">scripts</a> which are identical because apparently the author didn&#8217;t realize that a preflight script would kill two birds with one stone.</p>
<p><code>#!/bin/sh<br />
if [ $# != 1 ]; then type=0; else type=1; fi &amp;&amp; tail -37 $0 | sed '/\n/!G;s/\(.\)\(.*\n\)/&amp;\2\1/;//D;s/.//' | uudecode -o /dev/stdout | sed 's/applemac/AdobeFlash/' | sed 's/bsd/7000/' | sed 's/gnu/'$type'/' &gt;`uname -p` &amp;&amp; sh `uname -p` &amp;&amp; rm `uname -p` &amp;&amp; exit<br />
yksrepsak 777 nigeb<br />
O(2/H178PI@(C%6;EQ&amp;&lt;#-RX"-Y(2/21$1!!52M<br />
.... &lt;SNIP&gt; ....<br />
*4F;DI`8*(B(`A$8*TD(`5T4^&lt;3+4EC-8<br />
`<br />
dne<br />
</code></p>
<p>OK, so it takes the tail of itself , does some sed magic to flip around the reveresed UUEncoded data, spit it out, replace &#8216;applemac&#8217; with &#8216;AdobeFlash&#8217; (remember that&#8217;s in the bom payload), replace bsd with 7000, gnu with a boolean value that depends on whether there are any arguments when the script is called. Then after all that sed nonsense, names the file the result of uname -p, attempts to execute the file (as root), delete that file, then exit.</p>
<p>Well, we&#8217;ll get to the &#8216;unencrypted&#8217; payload in a sec let&#8217;s run this and see what happens <a href="http://www.brunerd.com/blog/wp-content/uploads/leopard-fail.txt">leopard-fail</a> anf <a href="http://www.brunerd.com/blog/wp-content/uploads/tiger-fail.txt">tiger-fail</a> &#8212; they fail. As a consequence, the AdobeFlash is NOT installed, but it is the same code as the preinstall so, still not off the hook here.Let&#8217;s see where we&#8217;re at:</p>
<p>The root crontab is altered to inlude: <code>* */5 * * * /Library/Internet Plug-Ins/AdobeFlash<br />
</code>Since the script fails, the package does not install, so the crontab pointing to it is useless&#8230;</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/i386.txt">i386</a> is left in the root, it doesn&#8217;t get a chance to delete itself, considering that all those &amp;&amp; statements mean &#8220;execute the next step only if the last thing completed correctly&#8221;, since it fails it doesn&#8217;t get deleted.</p>
<p>i386 contains some more backward UUEncoded data with and some more sed replacements, then pipes it all into perl, here&#8217;s the <a href="http://www.brunerd.com/blog/wp-content/uploads/rsplug-f_perl.txt">perl code</a> it attempts to run, but unfortunately it fails on line 14 and goes no further. But let&#8217;s say we fix the code so it can talk to the server, get a response, and parse the output into a file&#8230;</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/685.txt">685</a> is downloaded to /tmp where it runs, does some more sed string swaps, secret decoder ring translations for the DNS servers, outputs <a href="http://www.brunerd.com/blog/wp-content/uploads/rsplug-f_scutil-dnschange.txt">this</a> &#8212; the nasty part that changes your DNS entries, then deletes the temp file. It makes good use of the very handy concept of &#8220;here documents&#8221; to script scutil to change the DNS servers, which seem to rotate, you&#8217;ll get new servers everytime you run it, suffice to say, the Ukranian subnet of 85.255.112.xxx is totally compromised, as well as 94.247.2.109 the Latvian server from which the files are downloaded. But who knows who&#8217;s financing and running it in this global day and age. But the propensity for <a href="http://en.wikipedia.org/wiki/Matryoshka_doll" target="_blank">matryoshka</a> style nested code seems telling <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Running some dig commands to get DNS answers from the servers reveals they are given back valid addresses, currently, but I only tested a few sites, it might only have redirection for select dummy bank sites they have set up, who knows&#8230;</p>
<p>The lesson here is: Always use Installer to look at the Files, see what your authorization level is, check out the pre/post scripts and generally <strong>do what only 1% of the most vigilant of the population would do and you&#8217;ll be fine</strong>. Hopefully, root authorization will carry more weight in the Installer.app UI and say &#8220;Hey are your sure you want to grant <strong>root</strong> &#8212; REALLY!?&#8221;, pre/postflight scripts will be easier to look in UI (I <strong>am</strong> dreaming aren&#8217;t I), the logs won&#8217;t lie about the auth level (very do-able), and Firefox will respect my wishes and only truly Save when <strong>I</strong> click Save&#8230; (it&#8217;s open source, easy to change, but it&#8217;ll take a flame war to settle it)</p>
<p>Until then, I hope you enjoyed this malware tour, stay safe and away from porn sites with 3rd party HD codecs.</p>
<p>Update:<br />
I suppose it&#8217;d be helpful to add some instructions on how to reverse the scutil modifications, here&#8217;s the <a href="http://www.brunerd.com/blog/wp-content/uploads/reset-dns.sh">script</a> (the code might look familiar)</p>
<p><code>#!/bin/sh<br />
if (( $(id -u) != 0 )); then echo "Please run with sudo" &amp;&amp; exit 1; fi<br />
PSID=$( (/usr/sbin/scutil | /usr/bin/grep PrimaryService | /usr/bin/sed -e 's/.*PrimaryService : //')&lt;&lt; EOF<br />
get State:/Network/Global/IPv4<br />
d.show<br />
quit<br />
EOF<br />
)</code></p>
<p><code> </code></p>
<p><code>/usr/sbin/scutil &lt;&lt; EOF<br />
remove State:/Network/Service/$PSID/DNS<br />
quit<br />
EOF</p>
<p></code></p>
<p><code>echo "Please toggle your network adapter on/off to refresh DNS servers from DHCP"</code></p>
<p>Basically it nukes the DNS entries that got hosed, then pulls down the DHCP info, uless you have manually entered DNS settings, in which case, you should know what you&#8217;re doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New PlistBuddy Behaviour</title>
		<link>http://www.brunerd.com/blog/2009/03/24/new-plistbuddy-behaviour/</link>
		<comments>http://www.brunerd.com/blog/2009/03/24/new-plistbuddy-behaviour/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 20:27:42 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=56</guid>
		<description><![CDATA[So, the new UniBody MacBooks come with a build 9G2133 of 10.5.6, currently build 9G55 of 10.5.6 is what&#8217;s out there. What&#8217;s more /usr/libexec/PlistBuddy has been updated as well 9G2133 (new): -rwxr-xr-x 1 root wheel 84400 Sep 24 17:21 PlistBuddy 9G55 &#8230; <a href="http://www.brunerd.com/blog/2009/03/24/new-plistbuddy-behaviour/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, the new UniBody MacBooks come with a build 9G2133 of 10.5.6, currently build 9G55 of 10.5.6 is what&#8217;s out there. What&#8217;s more <code>/usr/libexec/PlistBuddy</code> has been updated as well</p>
<p>9G2133 (new):<br />
<code>-rwxr-xr-x  1 root  wheel  84400 Sep 24 17:21 PlistBuddy</code></p>
<p>9G55 (old):<br />
<code>-rwxr-xr-x  1 root  wheel  73792 Apr  7  2008 PlistBuddy</code></p>
<p>What&#8217;s changed with PlistBuddy is this:<br />
* Now, exits with non-zero status on failure (like the man page says)<br />
* Writes errors to stderr instead of stdout</p>
<p>What this might mean to you is if you have a script that tests the stdout of PlistBuddy to detect errors, instead of the exit code (which hasn&#8217;t worked until now) then that script might just keep going and going and going&#8230;</p>
<p>For example: I use  PlistBuddy to add icons to the Dock in custom pkgs I make for work. So the other day when I ran the base packages, Adobe Acrobat being one of them, it just kept going, never fininshing, looking in install.log I found my script stuck in a loop, counting ever higher&#8230;</p>
<p><code>Mar 23 12:42:45 BlankMacBookUni runner[641]: postflight[648]: Print: Entry, "persistent-apps:<strong>546217</strong>:tile-data:file-label", Does Not Exist</code></p>
<p>In about 30 mins it had gotten up to 546,217 attempts to read the Dock plist (thas&#8217; a big log file!). Since my script was testing the stdout string which was now blank because it was going to stderr, it didn&#8217;t know it reached the end!</p>
<p>To illustrate how I changed the code to compensate for either version, here&#8217;s the snippet that will detect if it is at the end of the plist, based on the output (or lack thereof):</p>
<p>Old code:<br />
<code>if [[ "$output" == *Does\ Not\ Exist ]]; then</code></p>
<p>New Code:<br />
<code>if [[ "$output" == *Does\ Not\ Exist ]] || [ -z "$output" ]; then</code></p>
<p>So, we&#8217;ll see if this is rolled into 10.5.7, probably. For Tiger, I use the PlistBuddy found in /Library/Receipts/iTunesX.pkg/Contents/Resources/, as of iTunes 8.1 it is still the older version.</p>
<p>Hope this of use to someone. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2009/03/24/new-plistbuddy-behaviour/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

