Monday, July 15, 2013

Switch Your Coding Life: Android - Check the database on DDMS

Switch Your Coding Life: Android - Check the database on DDMSAndroid utilizes the SQlite database by default. However, for security reasons, the sqlite3 is not installed on many Android devices (At least on Android 2.3.3). To work with it, one could root the phone and install sqlite3 by hand. The another way to do it is working with the emulator.

Because the emulator is a completely open device, there is not restriction to access to the database or to the shared preferences. Once the emulator has been started, the DDMS of eclipse could be used to extract the database and check its structure and the contents.

To make the thing even easier, there is a plugin for the eclipse which allow the coders to access the data inside of DDMS




How to browse an Android SQLite Database from Eclipse Kepler

http://pantestmb.blogspot.ro/2012/04/sqlite-plugin-for-eclipse.html




Tuesday, July 2, 2013

AVD hardware settings - keyboard


   After updating Eclipse ( Help Menu -> Check for Updates ) ,
running and debugging my application in the Android Virtual Device (AVD) was a nightmare :
   I couldn't use the computer keyboard anymore to enter data in my Android app;
( AVD's keyboard wasn't QWERTY ) ; Entering one digit number took 4 or 5 mouse-clicks :-(

No QUERTY AVD :



http://developer.android.com/tools/devices/managing-avds.html

After adding hardware keyboard support , problem solved :
Hardware property = "Keyboard Support"
Value = "yes"



Hardware options

If you are creating a new AVD, you can specify the following hardware options for the AVD to emulate:
CharacteristicDescriptionProperty
Device ram sizeThe amount of physical RAM on the device, in megabytes. Default value is "96".hw.ramSize
Touch-screen supportWhether there is a touch screen or not on the device. Default value is "yes".hw.touchScreen
Trackball supportWhether there is a trackball on the device. Default value is "yes".hw.trackBall
Keyboard supportWhether the device has a QWERTY keyboard. Default value is "yes".hw.keyboard
DPad supportWhether the device has DPad keys. Default value is "yes".hw.dPad
GSM modem supportWhether there is a GSM modem in the device. Default value is "yes".hw.gsmModem
Camera supportWhether the device has a camera. Default value is "no".hw.camera
Maximum horizontal camera pixelsDefault value is "640".hw.camera.maxHorizontalPixels
Maximum vertical camera pixelsDefault value is "480".hw.camera.maxVerticalPixels
GPS supportWhether there is a GPS in the device. Default value is "yes".hw.gps
Battery supportWhether the device can run on a battery. Default value is "yes".hw.battery
AccelerometerWhether there is an accelerometer in the device. Default value is "yes".hw.accelerometer
Audio recording supportWhether the device can record audio. Default value is "yes".hw.audioInput
Audio playback supportWhether the device can play audio. Default value is "yes".hw.audioOutput
SD Card supportWhether the device supports insertion/removal of virtual SD Cards. Default value is "yes".hw.sdCard
Cache partition supportWhether we use a /cache partition on the device. Default value is "yes".disk.cachePartition
Cache partition sizeDefault value is "66MB".disk.cachePartition.size
Abstracted LCD densitySets the generalized density characteristic used by the AVD's screen. Default value is "160".





Monday, May 13, 2013

DD-WRT OpenVPN Daemon Settings


http://pantestmb.blogspot.ro/2013/04/dd-wrt-openvpn-router-to-router.html
http://pantestmb.blogspot.ro/2013/04/setup-openvpn-client-to-connect-to-dd.html

Services

VPN
OpenVPN Daemon
OpenVPN Config : 

# Servers LAN route 

## Push route to server subnet onto all clients
push "route 192.168.61.0 255.255.255.0"
#
## Clients LAN route 
route 192.168.101.0 255.255.255.0 172.16.0.2
route 192.168.33.0 255.255.255.0 172.16.0.2
route 192.168.62.0 255.255.255.0 172.16.0.2
route 192.168.15.0 255.255.255.0 172.16.0.2
#
## Bug workaround, this is fixed in r17685
client-config-dir /tmp/openvpn/ccd
#
server 172.16.0.0 255.255.0.0
dev tun0
proto tcp
keepalive 10 120
dh /tmp/openvpn/dh.pem
ca /tmp/openvpn/ca.crt
cert /tmp/openvpn/cert.pem
key /tmp/openvpn/key.pem
management localhost 5001






Administration
Commands
Startup


mkdir -p /tmp/openvpn/ccd
echo "iroute 192.168.15.0 255.255.255.0" > /tmp/openvpn/ccd/bac15cli4res
echo "iroute 192.168.33.0 255.255.255.0" > /tmp/openvpn/ccd/dev03cli4res
echo "iroute 192.168.62.0 255.255.255.0" > /tmp/openvpn/ccd/buc06cli4res

Firewall


iptables -I INPUT -p tcp --dport 1194 -j ACCEPT
iptables -I INPUT -p tcp --source 192.168.61.0/24 -j ACCEPT
iptables -I INPUT -p tcp --source 192.168.101.0/24 -j ACCEPT
iptables -I INPUT -p tcp --source 172.16.0.0/16 -j ACCEPT
iptables -I INPUT -i tun0 -p icmp -j ACCEPT
iptables -I FORWARD --source 172.16.0.0/16 -p icmp -j ACCEPT
iptables -I FORWARD --source 192.168.15.0/24 -p icmp -j ACCEPT
iptables -I FORWARD --source 192.168.61.0/24 -p icmp -j ACCEPT
iptables -I FORWARD --source 192.168.62.0/24 -p icmp -j ACCEPT
iptables -I FORWARD --source 192.168.101.0/24 -p icmp -j ACCEPT
iptables -I FORWARD -p tcp --source 172.16.0.0/16 -j ACCEPT
iptables -I FORWARD -p tcp --source 192.168.101.0/24 -j ACCEPT
iptables -I FORWARD -p tcp --source 192.168.61.0/24 -j ACCEPT
iptables -I FORWARD -i br0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o br0 -j ACCEPT



If there is a gateway server - a routing command can be used :
route add -net 192.168.15.0 netmask 255.255.255.0 gw 192.168.16.49

Monday, April 29, 2013

DD-WRT OpenVPN Router To Router

Client Configuration - DD-WRT


This is the configuration for an OpenVPN Client running on another DD-WRT box.
Just set the OpenVPN server name (its WAN address or name) and port (1194) using the GUI, and then put in the certs similar to the procedure on the server:

BoxFile to insert
Public Server Certca.crt
Public Client Certsuc19cli4res.crt
Private Client Keysuc19cli4res.key


Thursday, April 25, 2013

Fedora 18 , sshd & SELiNUX

Trying to change the default port of sshd , selinux appeared :

service sshd status
Redirecting to /bin/systemctl status  sshd.service
sshd.service - OpenSSH server daemon
      Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
      Active: failed (Result: exit-code) since Thu 2013-04-25 16:01:52 EEST; 1min 25s ago
     Process: 1950 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
     Process: 1944 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)

 systemd[1]: Starting OpenSSH server daemon...
 systemd[1]: Started OpenSSH server daemon.
 sshd[1950]: error: Bind to port 248 on 0.0.0.0 failed: Permission denied.
 sshd[1950]: error: Bind to port 248 on :: failed: Permission denied.
 systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
 systemd[1]: Unit sshd.service entered failed state

everything is ok with :

semanage port -a -t ssh_port_t -p tcp 248





SELinux is preventing /usr/sbin/sshd from name_bind access on the tcp_socket .

*****  Plugin bind_ports (99.5 confidence) suggests  *************************

If you want to allow /usr/sbin/sshd to bind to network port 248
Then you need to modify the port type.
Do
# semanage port -a -t PORT_TYPE -p tcp 248
    where PORT_TYPE is one of the following: ssh_port_t, xserver_port_t.

*****  Plugin catchall (1.49 confidence) suggests  ***************************

If you believe that sshd should be allowed name_bind access on the  tcp_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep sshd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:sshd_t:s0-s0:c0.c1023
Target Context                system_u:object_r:reserved_port_t:s0
Target Objects                 [ tcp_socket ]
Source                        sshd
Source Path                   /usr/sbin/sshd
Port                          248
Host                          82-79-141-236.static.resita.rdsnet.ro
Source RPM Packages           openssh-server-6.1p1-6.fc18.x86_64
Target RPM Packages          
Policy RPM                    selinux-policy-3.11.1-91.fc18.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing

Platform                      Linux   3.8.8-202.fc18.x86_64 #1 SMP Wed Apr 17 23:25:17
                              UTC 2013 x86_64 x86_64
Alert Count                   1
First Seen                    2013-04-25 16:01:52 EEST
Last Seen                     2013-04-25 16:01:52 EEST
Local ID                      fffbad56-ad32-4ff4-b98d-3de411d41505

Raw Audit Messages
type=AVC msg=audit(1366894912.989:94): avc:  denied  { name_bind } for  pid=1950 comm="sshd" src=248 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:reserved_port_t:s0 tclass=tcp_socket


type=SYSCALL msg=audit(1366894912.989:94): arch=x86_64 syscall=bind success=no exit=EACCES a0=3 a1=7ff6baf563b0 a2=1c a3=7fffe9432d74 items=0 ppid=1 pid=1950 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm=sshd exe=/usr/sbin/sshd subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 key=(null)

Hash: sshd,sshd_t,reserved_port_t,tcp_socket,name_bind

audit2allow

#============= sshd_t ==============
allow sshd_t reserved_port_t:tcp_socket name_bind;

audit2allow -R
require {
    type sshd_t;
}

#============= sshd_t ==============
corenet_tcp_bind_reserved_port(sshd_t)

Fedora 18 , yum groupinstall , systemd


yum groupinstall "GNOME Desktop"
yum groupinstall "MATE-Desktop"
yum groupinstall cinnamon


How do I change the default runlevel? 

rm /etc/systemd/system/default.target 
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

SysVinit to Systemd Cheatsheet

 

Services

Sysvinit Command Systemd Command Notes
service frobozz start systemctl start frobozz.service Used to start a service (not reboot persistent)
service frobozz stop systemctl stop frobozz.service Used to stop a service (not reboot persistent)
service frobozz restart systemctl restart frobozz.service Used to stop and then start a service
service frobozz reload systemctl reload frobozz.service When supported, reloads the config file without interrupting pending operations.
service frobozz condrestart systemctl condrestart frobozz.service Restarts if the service is already running.
service frobozz status systemctl status frobozz.service Tells whether a service is currently running.
ls /etc/rc.d/init.d/ systemctl list-unit-files --type=service (preferred)
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
Used to list the services that can be started or stopped
Used to list all the services and other units
chkconfig frobozz on systemctl enable frobozz.service Turn the service on, for start at next boot, or other trigger.
chkconfig frobozz off systemctl disable frobozz.service Turn the service off for the next reboot, or any other trigger.
chkconfig frobozz systemctl is-enabled frobozz.service Used to check whether a service is configured to start or not in the current environment.
chkconfig --list systemctl list-unit-files --type=service(preferred)
ls /etc/systemd/system/*.wants/
Print a table of services that lists which runlevels each is configured on or off
chkconfig frobozz --list ls /etc/systemd/system/*.wants/frobozz.service Used to list what levels this service is configured on or off
chkconfig frobozz --add systemctl daemon-reload Used when you create a new service file or modify any configuration
Note that all /sbin/service and /sbin/chkconfig lines listed above continue to work on systemd, and will be translated to native equivalents as necessary. The only exception is chkconfig --list.

Runlevels/targets

Systemd has a concept of targets which serve a similar purpose as runlevels but act a little different. Each target is named instead of numbered and is intended to serve a specific purpose. Some targets are implemented by inheriting all of the services of another target and adding additional services to it. There are systemd targets that mimic the common sysvinit runlevels so you can still switch targets using the familiar telinit RUNLEVEL command. The runlevels that are assigned a specific purpose on vanilla Fedora installs; 0, 1, 3, 5, and 6; have a 1:1 mapping with a specific systemd target. Unfortunately, there's no good way to do the same for the user-defined runlevels like 2 and 4. If you make use of those it is suggested that you make a new named systemd target as /etc/systemd/system/$YOURTARGET that takes one of the existing runlevels as a base (you can look at /lib/systemd/system/graphical.target as an example), make a directory /etc/systemd/system/$YOURTARGET.wants, and then symlink the additional services that you want to enable into that directory. (The service unit files that you symlink live in /lib/systemd/system).
Sysvinit Runlevel Systemd Target Notes
0 runlevel0.target, poweroff.target Halt the system.
1, s, single runlevel1.target, rescue.target Single user mode.
2, 4 runlevel2.target, runlevel4.target, multi-user.target User-defined/Site-specific runlevels. By default, identical to 3.
3 runlevel3.target, multi-user.target Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.
5 runlevel5.target, graphical.target Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.
6 runlevel6.target, reboot.target Reboot
emergency emergency.target Emergency shell

Changing runlevels:
Sysvinit Command Systemd Command Notes
telinit 3 systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) Change to multi-user run level.
sed s/^id:.*:initdefault:/id:3:initdefault:/ ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target Set to use multi-user runlevel on next reboot.

systemd command reference
sysVinit command systemd command Notes
service sshd start systemctl start sshd.service Used to start a service (not reboot persistent)
service sshd stop systemctl stop sshd.service Used to stop a service. (not reboot persistent)
service sshd restart systemctl restart sshd.service Used to start and stop a service.
service sshd reload systemctl reload sshd.service When supported, reloads the config file without interrupting pending operations.
service sshd condrestart systemctl condrestart sshd.service Restarts if the service is already running.
service sshd status systemctl status sshd.service Tells whether a service is currently running.
ls /etc/rc.d/init.d/ systemctl list-unit-files --type=service Lists all available services.
chkconfig sshd on systemctl enable sshd.service Always run the service at this target (runlevel.)
chkconfig sshd off systemctl disable sshd.service Do not automatically run the service at this target (runlevel.)
chkconfig --list systemctl list-units -t service --all Print a table of available services and their status.
chkconfig sshd --list ls /etc/systemd/system/*.wants/sshd.service Lists the targets that will include the service.
chkconfig sshd --add systemctl daemon-reload Used when you create a service file or modify any configuration.
telinit 3 systemctl isolate multi-user.target Move system into another target (change runlevels.)
[no comparable command] systemctl show -p "Wants" multi-user.target Lists units pulled in by a given target.
[no comparable command] systemctl show -p "After" sshd.service Shows dependent services and other targets.
[no comparable command] systemd --test --system --unit=multi-user.target Simulates booting the system to a given target
[no comparable command] systemd-analyze plot > boot.svg Generates a diagnostically useful graphical representation of the boot process.
ps xawf -eo pid,user,cgroup,args systemd-cgls Display control group process tree.

Tuesday, April 23, 2013

HDD speed can bottleneck gigabit transfer

http://www.tomshardware.co.uk/forum/29448-42-network-adapter-100mb-speed

Suggestion:


1. Cat 6 cable should squeeze more speed out of your connection

2. Cable length - Keep it as short as possible
3. Your best speed results will be between 2 computers with gigabit connections. Internet usage speeds will be lower in most cases.
4. Make sure jumbo frames are set in network properties for your network adapter. Set to the max value which is 9k. 
5. Hard Disk speed can bottleneck your gigabit transfers

http://www.wikihow.com/Upgrade-Your-Network-to-Gigabit-Ethernet





Hard Drive Delivers SATA-III 6-Gbit/s Transfer Rate


http://electronicdesign.com/boards/hard-drive-delivers-sata-iii-6-gbits-transfer-rate

Will a Gigabit Switch Speed Up My Home Network?
http://www.ehow.com/info_12215278_gigabit-switch-speed-up-home-network.html#ixzz2RJpBXjUQ