Udgivet den

Windows 7 – never Launch Startup Repair

Do this command:

bcdedit /set {current} bootstatuspolicy ignoreallfailures

Similar is

bcdedit /set {default} bootstatuspolicy ignoreallfailures

They can be the same if you are booted into the default load, so default would equal current.

For more information, the relevant Google search is “disable Windows Error Recovery” (minus the quotes).

Udgivet den

Swap area in OpenSUSE

First create an 1Gigabyte file.

opensuse:~# dd if=/dev/zero of=/swap   bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 28.7256 s, 35.6 MB/s

DD command to create the 1G file basically writing “0” into the file swap_1 in the “/” file system.

Create SWAP area

opensuse:~ # mkswap /swap
Setting up swapspace version 1, size = 999996 KiB
no label, UUID=4aada58e-d6f7-4053-adf1-8d4c79122d36

That sets up the file as a swap area.

Now, we’ll simply enable the swapfile, so that the system can start paging physical memory pages onto it.

opensuse:~ # swapon /swap

The system should now have an additional 1Gigabyte of swap area. Check it.

opensuse:~ # free -tom
total       used       free     shared    buffers     cached
Mem:           998        973         24          0         20        795
Swap:         1716          0       1716
Total:        2714        973       1741

We now have 1.7Gigabytes of swap area.

To confirm the swap areas we have

opensuse:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/system-swap                 partition       757752  0       -1
/swap                                      file            999992  0       -2

To make it permanent, we need to add an entry to the /etc/fstab file.:

/swap       swap                 swap       defaults              0 0

Where /swap is our new swap file and it instructs the system to mount it at system startup as a swap area.

Udgivet den

Secure AXIGEN against brute-force with Fail2Ban [Linux]

Fail2Ban (http://wikipedia.org/wiki/Fail2ban) protects your server against intruders who try brute force to guess passwords.
Enables you to monitor standard services such as SSH, Apache, etc..

Furthermore, AXIGEN can be secured against password attacks.

The following steps are necessary:
The steps may differ depending on your distribution.

Step 1: Install Fail2Ban
Step 2: Create a shell script:

#!/bin/bash
# $1 - log file to be used
LOG_AXI="/var/opt/axigen/log/everything.txt"
if [ -z "$1" ]
 then
 LOG_SEC=/var/opt/axigen/log/secure.txt
 else
 LOG_SEC="$1"
 fi
tail --retry --follow=name "$LOG_AXI" | while read l
 do
 timestamp=$(date '+%d-%m-%Y %T')
 case "$l" in
 *"Authentication error"*|*"could not authenticate user"*|*"error authenticating user"*) sid=$(echo "$l" | awk '{print $6}')
 if [ -n "$sid" ]
 then
 con_ip=$(grep -m 1 $sid "$LOG_AXI" | awk '{print $NF}' | sed 's/\[//g;s/:.*$//g')
 if [ -n "$con_ip" ]
 then
 echo "$timestamp $l from $con_ip" >> "$LOG_SEC"
 fi
 fi
 ;;
 esac
 done

Step 3: Make sure that there script runs automatically, for example, /etc/inittab

Notes:
If AXIGEN writes the log file to another location, please kindly adjust the path to the variable $ LOG_AXI.
For secure.txt file a log Rotate should be established
Test the script as follows:
Start the script
Check the contents of secure.txt
Run a false login with, this should be reported as follows

18-07-2014 14:35:42 07-28 14:35:42 +0300 02 localhost IMAP:000000CC: Authentication error for user ‘user1@localdomain’: Invalid password from 192.168.1.101

Step 4: Create a new module Fail2Ban to, for example, axigen.cfg under /etc/fail2ban/filter.d
With content:

# Fail2Ban configuration file
[Definition]
failregex = from <HOST>

Step 5: Configure Fail2Ban where you expand the jail.conf under /etc/fail2ban to block the following:

[axigen]
enabled = true
filter = axigen
port = all
logpath = /var/opt/axigen/log/secure.txt
bantime = 100
maxretry = 3
banaction = iptables-allports

The maximum number of failed attempts, spell-time and path please adjust accordingly.
Then please restart fail2ban.

 

From http://www.axigenmailgate.de/forum/archive/index.php/t-935.html

Udgivet den

Block or redirect using mod_geoip

Installing mod_geoip allows you to block or redirect traffic based on the geografical location of the client using the IP-address of the client. mod_geoip for CentOS is available at the EPEL repository. If you haven’t setup the EPEL repository follow the instructions explained on their website. I asume you allready installed Apache. Download and install mod_geoip, GeoIP and the related libraries:

yum install GeoIP GeoIP-devel GeoIP-data zlib-devel mod_geoip

As MaxMind regularly update their database files you might choose to download the file manually using by a cronjob. Create a bash script which download and install the GeoLite databases. This example is base on the GeoLite version, if you have a subscription your change the according lines to download the appropiate database files:

#!/bin/bash
#Download Maxmind GeoIP databases
cd /var/lib/GeoIP
mv GeoIP.dat GeoIP.dat.old
/usr/bin/wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
/usr/bin/wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoIP.dat.gz
gunzip GeoLiteCity.dat.gz

Make this script executable:

chmod 750 SCRIPTNAME.SH

and edit your crontab to run this script every 3rd day of the month:

crontab -e
0 0 3 * * /PATH_TO_SCRIPT/SCRIPTNAME

Edit the configuration file /etc/httpd/conf.d/mod_geoip.confand activate the module and change the path of the database. (GeoLiteCity.dat also returns the CityNames and the geographic locations):

LoadModule geoip_module modules/mod_geoip.so
<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPDBFile /var/lib/GeoIP.dat
</IfModule>

and restart Apache:

/ect/init.d/apache restart

Now create a .htaccess file. For example if you want to block clients from Russia and China:

SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
Deny from env=BlockCountry

If you want to redirect based on the country using mod_rewrite in combination with mod_geoip, your .htaccess file could look like this:

RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(NL|BE)$
RewriteRule ^(.*)$ http://www.mydomain.com/nl/$1 [L]

For more example take a look at he website of MaxMind

Copy from http://www.linux-faqs.info/apache/block-or-redirect-using-mod-geoip

Udgivet den Skriv en kommentar

Set the PATH in Win 7 to NPM, GIT, Cordova and Android

ANDROID_HOME
C:\somewhere

JAVA_HOME
C:\somewhere

ANDROID_HOME
C:\somewhere

ANT_HOME
C:\somewhere

PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%ANDROID_HOME%\tools\;%ANDROID_HOME%\platform-tools\;%JAVA_HOME%\bin\;%ANT_HOME%\bin\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;C:\Users\User\AppData\Roaming\npm

Udgivet den Skriv en kommentar

Android WakeLock + Cordova 3.*

Google Developer PowerManager

I Manifestet brug:

 <uses-permission android:name="android.permission.WAKE_LOCK" />

I activity*.java læg til det med tykt markeret. 

import android.os.Bundle;
import org.apache.cordova.*;
import android.view.WindowManager;
public class Tutix extends CordovaActivity
 {
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
super.onCreate(savedInstanceState);
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
 // Set by <content src="index.html" /> in config.xml
 loadUrl(launchUrl);
 }
 }

Under layout:

android:keepScreenOn="true">

That’s it.