Tag Archives: passwords

integrating wordpress into existing site – part 2

11 Mar

I realized I left out alot while reading part1, so i’m covering more here, an possibly in additional posts

disable plugins if not in wordpress 

You’ll need to use wordpress on the backend from time to time, mostly for login / logout functionality. You should build a connector class to handle this. When using wordpress via your class outside of your actual wordpress install you should disable you wordpress plugins. why? less to load, and i’ve found some plugins have issues when loaded by wordpress outside of the actual wordpress installation.

 in wp-settings.php near line 231 replace

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}

with

if(!defined(‘NO_PLUGINS’)){

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}
}

What we just did was change the plugin loading portion of wordpress to not load plugins if we define the NO_PLUGINS flag.

Loading wordpress for your connector class 
In your class file you should load the required wordpress files before your class. Something like:

if(!defined(‘DB_NAME’)) {
define(‘NO_PLUGINS’,true);
require_once(FS_WORDPRESS.’/wp-config.php’);

}

 I’m checking for wordpress by looking to see if the DB_NAME is defined. This check will tell if we’re already in wordpress, its not rocket scienece just a check for a wordpress only varibale. If it’s not defined then plugins are disabled. simple right?

 login user to wordpress at site login.

When a user logs into your site, they should automaticly be logged into wordpress. this is of course assuming that your not trying to actually keep wordpress seprated, but then again that defeats the purpose of this thing that somehow turned into a tut (pardon me i seriously need some sleep)

 wordpress was loaded via the previous code, now we’ll still need to load the specific files that contain our required wordpress functions.

require_once( ABSPATH . WPINC . ‘/registration.php’);
require_once(FS_LIBRARY.’/User.inc’);

By loading the registration.php file we’ll now have all the functions needed for handling wordpress login, logout, and registration functions. Why do we want to register a user? simple new users (or old users if you don’t want to write an import script.

the following is of course assuming that your site is setup correctly.  when a new or current user attempts to login we’ll check to see if that user can in fact login or exists. if the user exists its safe to assume that they have updated their password on the main site, so we’ll update their password, and attempt to login again. for users who aren’t already in the wordpress db, we’ll run the wordpress registration functions ( removing their validation requirement of course ). because wordpress is running as an addon to your current saite, your actual site should be handling user checking etc, and only allow valid users access to this area, and only if their username matches the user session ( sorry not covering all that right now).

heres some sample code, please note your passwords shouldn’t be in plain text format, but this sampleuses plain text passcodes to show how. you can remove the md5 functions and do your own thing from there

    /*this function adds a user to wordpress, their is no error checking as users are checked, updated, created at login*/
function register($username, $password, $email){
global $wpdb;
//make sure we have a user

if(!empty($username) && !username_exists( $username )){
/*create user and update their wordpress account to not require activation*/
@create_user($username, $password, $email);
$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$password’), user_activation_key = ” WHERE user_login = ‘$username’”);
}
}

/*this function is only called from the login function in your  site user class
at the point its called we have a valid user, so we need to make sure the user can access wordpress*/
function login($user_login, $user_pass){
global $wpdb, $_SERVER;

//attempt login
$logged_in=@wp_login($user_login, $user_pass);
/*if login fails but user name exist
then user was created by an admin
so we’ll reset their wordpress password and update their email address, just in case they changed it*/
if(!$logged_in && username_exists( $user_login )){
$user    =&new YourUserClass($user_login);

$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$user_pass’), user_email=’”.$user->emailAddress().”‘ WHERE user_login = ‘$user_login’”);
}else{
/*the user hasn’t been added to wordpress, add them */
$user    =&new YourUserClass($user_login);

WordPressConnector::register($user->userName(), $user->password(), $user->emailAddress());

}
do_action_ref_array(‘wp_authenticate’, array(&$user_login, &$user_pass));

//ok we now have a valid wordpress user
//if not logged in then login user
$logged_in=(!$logged_in) ? @wp_login($user_login, $user_pass) : $logged_in;

if($logged_in){
wp_setcookie($user_login, $user_pass, false, ”, ”, true);
do_action(‘wp_login’, $user_login);


}

return $logged_in;
}

function logout(){
global $_SERVER;
wp_clearcookie();
do_action(‘wp_logout’);  


your_site_redirect_function();
}

 

If you have any questions, leave a comment, or just leave a comment if this was helpful.

 

Sid

it's simple – a fun link to have

1 Sep

jetman posted a comment on my TRYNT post about some other password services. although this isn’t a web service i like it.

I have a random password generator here, but i’m not always on systems with flash. so it’s simple is a good tool to have, not to mention i used it’s nick name generator to get names for me and some friends when we went out : hi my name Borin Doompick – breaker of stuff, destroyer of things.

check it out : http://www.itsimpl.com/

hi my name is coded

29 May

Here is my strong password generator project : hi my name is coded.
project page : http://elsid.net/hi-my-name-is-coded/
version : .1

It generates strong passwords using entered phrases, add salt, use or not use special characters, or blacklist characters, and can validate them using the TRYNT Password Security Web Service.

The TRYNT Password Security Web Service features

  • Dictionary Check
  • Length Check
  • Heterogeneity Check
  • Blacklisted Word Check
  • Blacklisted Character Check
  • Phonetic Check
  • Similarity Check
  • Superset/Subset Check

at the current time Trynt doesn’t have a crossdomain file, I’ve notified them, but until they do: validation only works when running the file local

hi my name is coded

Source : http://elsid.net/wp-content/uploads/2007/05/himynameiscoded.zip

enjoy – sid

Blacklisted characters index with details

28 May

After looking for about the past hour i finally found a index of black listed characters

IDN addresses have recently come under close scrutiny, mostly due to domain registrars failing to follow certain guidelines that help prevent a type of website spoofing attack.

Mozilla’s first response to the threat of this type of spoofing was to disable IDN support and instead display the more verbose form of IDN URLs—punycode. (Punycode bears little resemblance to the intended appearance of an IDN, removing the risk of spoofing.)

Go There : http://kb.mozillazine.org/Network.IDN.blacklist_chars

Also Found another one : http://www.fileformat.info/info/unicode/idn_blacklist.htm

password strength web service

28 May

found an awesome password strength web service. i’ll be using it for the hi my name is coded project.

From the page :

The TRYNT Password Security Web Service is designed to maintain password security. While user supplied passwords are notoriously insecure there are a number of factors that contribute. The TRYNT Password Security Web Service can verify password strength by checking all of the following:

* Dictionary Check
* Length Check
* Heterogeneity Check
* Blacklisted Word Check
* Blacklisted Character Check
* Phonetic Check
* Similarity Check
* Superset/Subset Check

In addition to verifying password strength the TRYNT Password Security Web Service can also generate strong passwords between 8-20 characters long. Please note this web service does not log any username and password combinations.

http://www.trynt.com/trynt-password-security-api/

Targeted password cracking – Proof of concept

28 May

Found an interesting read on using a sites registration system to built a cracking engine

From : http://myappsecurity.blogspot.com/2007/01/targeted-password-cracking-proof-of.html

This is a proof of concept to exploit the registration functionality of a website to build targeted password cracking engine. I am using Ajax to automatically detect the parameters which are submitted for a successful password and automatically resubmitting the modified passwords. Of course other technologies can be used for the same.

View Article : http://myappsecurity.blogspot.com/2007/01/targeted-password-cracking-proof-of.html

strong passwords required

26 Apr

Well its time for me to do a new passcode sweep. what sucks most about doing it is you have to come up with a new set of passcodes that have a decent amount of strength, and that you can remember, i try to make online one backup of my passcodes. and then keep it in a secure place.
so now i’ve got about 2 decent passwords i’ll remember. i need 4 total – lol, oh yeah forgot to mention, i try to never repeat a passcode, so once i’ve used a code once in a routation then it goes away into a different backup file thats got the passwords from the past 2 years.
been thinking about just coming up with a simple way of encoding everything but who knows. anywayz night