Blog Posts per Category

Assign IPs to geographical location

Assign IPs to geographical Location is quite interessting: if you know where visitors come from. you can redirect them to the web shop of their country, you can keep some countries away of your SSH daemon or showing special offers or events of this country. Of course this is not bullet proof. If your visitors using proxies located in a different country, anonymizer like TOR or accessing the internet by VPN so GeoIP won’t work as expected.

Read More →

Use DNS Blacklists in PHP

The following snippet is a quick and simple way to use dnsbl in PHP code (or for CLI use), if an IP is listed the code will return 1: <?php /* * Simple DNSBL check * Author: René Moser */ // Check this IP $ip = '201.2.6.141'; // List of DNSBL DNS Servers $dns_black_lists = file('./dnsbl.txt', FILE_IGNORE_NEW_LINES); // Reverse the IP $rev_ip = implode(array_reverse(explode('.', $ip)), '.'); $response = array(); foreach ($dns_black_lists as $dns_black_list) { $response = (gethostbynamel($rev_ip .

Read More →

LDAP Authentication using Java

import javax.naming.*; import javax.naming.directory.*; import java.util.Hashtable; /** * Demonstrates how to create an initial context to an LDAP server * using simple authentication. */ class Simple { public static void main(String[] args) { Hashtable authEnv = new Hashtable(11); String userName = "johnlennon"; String passWord = "sushi974"; String base = "ou=People,dc=example,dc=com"; String dn = "uid=" + userName + "," + base; String ldapURL = "ldap://ldap.example.com:389"; authEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); authEnv.put(Context.PROVIDER_URL, ldapURL); authEnv.put(Context.SECURITY_AUTHENTICATION, "simple"); authEnv.put(Context.SECURITY_PRINCIPAL, dn); authEnv.

Read More →

Meta