I needed to upload some backups, then move them to my /home directory. I only use Linux a little bit, not even every day (But moreso recently), so sometimes the simple things are hard.
I was doing this:
mv backup-9.16.2010_15-28-13_user.tar.gz /home/backup-9.16.2010_15-28-13_user.tar.gz
and then repeating for each file. Then I tried
mv backup-9.16.2010*.gz /home/backup-9.16.2010*.gz
and got an error that /home/backup-9.16.2010*.gz was not a directory, leading me to understand that
mv backup-9.16.2010*.gz /home
Was all I needed.
The author worked as a PHP / MySQL programmer for a Tampa Web Design Company for several years. He has now started his own Web Developer company and is recruiting clients.
Friday, September 17, 2010
Thursday, September 2, 2010
Site Hacks
I found out today how some site attacks have gotten through. They used "../" to traverse directories in my include files and find a file that, when loaded, would include the contents of thier User-Agent string. Then they put php code into their User-Agent string and re-visited the site with that specially corrupted query string and BAM! they were in.
The solution: sanitze the query string to exclude the double dot.
written like this:
\.\.
for regex matching.
That's one less open door!
Update: 2010-09-07:
For the attack above to work, the null byte had to be parsed. (all my includes had the extension concatenated to the end of the query string value. The null byte "%00" was used to make PHP ignore the concatenation.) In PHP4, magic_quotes_gpc would prevent this. In PHP5, magic_quotes_gpc is deprecated. Only sites using PHP5 were effected on my server.
The solution: sanitze the query string to exclude the double dot.
written like this:
\.\.
for regex matching.
That's one less open door!
Update: 2010-09-07:
For the attack above to work, the null byte had to be parsed. (all my includes had the extension concatenated to the end of the query string value. The null byte "%00" was used to make PHP ignore the concatenation.) In PHP4, magic_quotes_gpc would prevent this. In PHP5, magic_quotes_gpc is deprecated. Only sites using PHP5 were effected on my server.
Thursday, August 20, 2009
More Array Stuff
Using the code in my previous post, I disabled the existing echos and tried this:
$selected_array='test_array';
echo("{${$selected_array}['first']}");
echo("{${$selected_array}['array2'][1]}");
?>
The output was
1b
As expected, so I can access the array I need based on the $selected_array var.
$selected_array='test_array';
echo("{${$selected_array}['first']}");
echo("{${$selected_array}['array2'][1]}");
?>
The output was
1b
As expected, so I can access the array I need based on the $selected_array var.
PHP mixed arrays
I wanted to verify that I could mix scalar data and array data in the same array. Here's what I came up with.
$test_array=array(
'first'=>'1',
'second'=>'2',
'array1'=>array('begin'=>'one','middle'=>'2','end'=>'three'),
'array2'=>array('a','b','c')
);
echo ("first is {$test_array['first']}
");
echo ("second is {$test_array['second']}
");
echo ("array1 begin is {$test_array['array1']['begin']}
");
echo ("array1 middle is {$test_array['array1']['middle']}
");
echo ("array1 end is {$test_array['array1']['end']}
");
$count=0;
foreach ($test_array['array2'] as $value){
echo("array2 key $count is $value
");
$count++;
}
?>
The output was:
first is 1
second is 2
array1 begin is one
array1 middle is 2
array1 end is three
array2 key 0 is a
array2 key 1 is b
array2 key 2 is c
This means we can use mixed data in one array and access the scalar and composite data as expected.
$test_array=array(
'first'=>'1',
'second'=>'2',
'array1'=>array('begin'=>'one','middle'=>'2','end'=>'three'),
'array2'=>array('a','b','c')
);
echo ("first is {$test_array['first']}
");
echo ("second is {$test_array['second']}
");
echo ("array1 begin is {$test_array['array1']['begin']}
");
echo ("array1 middle is {$test_array['array1']['middle']}
");
echo ("array1 end is {$test_array['array1']['end']}
");
$count=0;
foreach ($test_array['array2'] as $value){
echo("array2 key $count is $value
");
$count++;
}
?>
The output was:
first is 1
second is 2
array1 begin is one
array1 middle is 2
array1 end is three
array2 key 0 is a
array2 key 1 is b
array2 key 2 is c
This means we can use mixed data in one array and access the scalar and composite data as expected.
Wednesday, July 15, 2009
MS Does it right? IE8
I am not a huge fan of Microsoft because I generally don't trust corporate giants and their software tends to bloat.
That being said, I am hearing and experiencing good things regarding IE8. I have heard that it is the most standards compliant browser. That's a good thing right? Not if the site you are visiting relied on old IE7 functionality. Well, that's where the Compatibility Button comes in handy! Then, theres the inPrivate Browsing, and the ability to delete items, one by one, from the address bar MRU.
I hate to admit it, but I kind of like this MS Product. Let's see if my opinion of that remains in the next few weeks.
That being said, I am hearing and experiencing good things regarding IE8. I have heard that it is the most standards compliant browser. That's a good thing right? Not if the site you are visiting relied on old IE7 functionality. Well, that's where the Compatibility Button comes in handy! Then, theres the inPrivate Browsing, and the ability to delete items, one by one, from the address bar MRU.
I hate to admit it, but I kind of like this MS Product. Let's see if my opinion of that remains in the next few weeks.
Tuesday, July 14, 2009
Back to Normal
I have returned my blog to it's normal appearance. I am not completely satisfied with the FTP integration, but it might work.
Subscribe to:
Posts (Atom)