Saturday, November 5, 2016

pfSense (2.3.2-RELEASE-p1) and SquidGuard (1.14_4)

I've been spending so much time to block a custom URL which isn't part of the blacklist. Here is what needs to be done.


  1. Create your Target categories (e.g.: iflix | iflix.com) and save it. With emphasis on "save" or whatever makes the change stick!
  2. Go to Common ACL > Target Rules List and select the new category created - either allow or deny it. Denying the category for testing is easy. :)
  3. Go to General settings and click Apply the Save at the bottom of the page.
Test your new category if it gets blocked. You can also verify by going to Log > Blocked and see if the domain/URL gets blocked.

Sunday, September 11, 2016

Laravel 5.3 and Migration

After running this command

php artisan make:migration create_nerds_table --table=nerds --create

I started modifying the generated file to complete the database then ran this

php artisan migrate

and unfortunately, it was giving this error.


After comparing notes (this and another project which ran successful - still in progress), I noticed the difference in the migration file.

The "make:migration" command generated a migration file that uses "Schema::table". The command "php artisan migrate" worked after changing the said part to "Schema::create".

Hope this helps. The environment is on VMware running Ubuntu 14.04 LTS with Apache, PHP5.x, and MariaDB.



Saturday, August 27, 2016

Ordinary User and WinSCP on Ubunut 14.04

WinSCP is a creature comfort. Transferring of files is a breeze but nowadays "root" isn't allowed to login and requires "sudo" which you can't run since the app is GUI and not terminal. There is a solution: SFTP and some settings that need to be changed.

Procedure:
  1. Edit sudoer and add this line "<user> ALL=NOPASSWD: /usr/lib/openssh/sftp-server".
  2. Go to WinSCP and edit your connection. Select SFTP, click "Advanced", look for the SFTP setting page and put this in: "sudo /usr/lib/openssh/sftp-server"
Note: check the actual directory of the file. It may be stored somewhere else

Here is another option



Ubuntu 14.04 and Laravel on Apache

Here is the fastest and straight forward guide to setup Ubuntu 14.04 with Apache-Laravel

https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

That's about it. :)

Saturday, August 20, 2016

SQL Server Connection from Ubuntu 14.04 and SQL Server using FreeTDS

So, everything is installed properly and it is time to test database connection to SQL Server. Here are some of my pointers:


  • Install FreeTDS and PHP with support for Sybase/SQL Server
  • Configure "odbcinst.conf"
[FreeTDS]
Description = FreeTDS Driver v0.91
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
fileusage = 1
dontdlclose = 1
UsageCount = 1
Note: just change to the correct path on the two modules
  • Configure "freetds.conf
[database_server_name]
host = 192.168.101.102
port = 1433
tds version = 4.2
client charset = UTF-8
Note: "database_name" is NOT the instance

  •  Configure "odbc.ini"

[jiradb]
Driver = FreeTDS
Servername = database_name_name
Port = 1433
Database = database_under_instance
TDS_Version = 4.2
Notes:

    • "Driver" field is the name header in "odbcinst.conf"
    • "Servername" field is the database header in "freetds.conf"
    • "Database" field is the target database under the instance
    • TDS_Version - run the command "tsql -C" and you should get the value
To connect:
isql database_server_name -U sa -P password
This is not a complete guide. Be sure to check the links below for further info.





SQL Server Connection from Ubuntu 14.04 and SQL Server using FreeTDS

So, everything is installed properly and it is time to test database connection to SQL Server. Here are some of my pointers:


  • Install FreeTDS and PHP with support for Sybase/SQL Server
  • Configure "odbcinst.conf"
[FreeTDS]
Description = FreeTDS Driver v0.91
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
fileusage = 1
dontdlclose = 1
UsageCount = 1
Note: just change to the correct path on the two modules
  • Configure "freetds.conf
[database_server_name]
host = 192.168.101.102
port = 1433
tds version = 4.2
client charset = UTF-8
Note: "database_name" is NOT the instance

  •  Configure "odbc.ini"

[jiradb]
Driver = FreeTDS
Servername = database_name_name
Port = 1433
Database = database_under_instance
TDS_Version = 4.2
Notes:

    • "Driver" field is the name header in "odbcinst.conf"
    • "Servername" field is the database header in "freetds.conf"
    • "Database" field is the target database under the instance
    • TDS_Version - run the command "tsql -C" and you should get the value
To connect:
isql database_server_name -U sa -P password
This is not a complete guide. Be sure to check the links below for further info.





Saturday, August 13, 2016

Error Connecting to pfSense 2.3 using Putty

I forgot got the error and simply updating your "putty.exe" to the latest fixed the problem. Here are some pointers as well:

"Couldn't agree a key exchange algorithm (available: curve25519-sha256@libssh.org"


  • Firewall rule(s)
  • NAT/port forward rule(s)
  • Gateway - well, quite far but I was doing a port forward of RDP for several hours that my target host gateway uses a different firewall :(

I'll update this post once I get to remember what particular error I encountered.


Error Connecting to pfSense 2.3 using Putty

I forgot got the error and simply updating your "putty.exe" to the latest (Release 0.67) fixed the problem. Here are some pointers as well:


"Couldn't agree a key exchange algorithm (available: curve25519-sha256@libssh.org"
  • Firewall rule(s)
  • NAT/port forward rule(s)
  • Gateway - well, quite far but I was doing a port forward of RDP for several hours that my target host gateway uses a different firewall :(

I'll update this post once I get to remember what particular error I encountered.


JIRA on AWS EC2 t2.micro

Finally, we were able to setup a demo of JIRA on AWS EC2 t2.micro.  Initially, it crashed due to insufficient memory...

The solution: instead of upgrading the instance type, just add SWAP :)


  1. Create a new EBS volume
  2. Attached it to the EC2 instance
  3. Start the instance and configure the new storage to be swap/swap file

Disk /dev/xvdg: 1073 MB, 1073741824 bytes

139 heads, 8 sectors/track, 1885 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfc4b3755

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdg1            2048     2097151     1047552   82  Linux swap / Solaris

ubuntu@iemijira:/$ free -h
             total       used       free     shared    buffers     cached
Mem:          992M       914M        78M        16K       2.2M        25M
-/+ buffers/cache:       886M       106M
Swap:         1.0G        12M       1.0G

Not sure when will I update this one :)

JIRA on AWS EC2 t2.micro

Finally, we were able to setup a demo of JIRA on AWS EC2 t2.micro.  Initially, it crashed due to insufficient memory...

The solution: instead of upgrading the instance type, just add SWAP :)
  1. Create a new EBS volume
  2. Attached it to the EC2 instance
  3. Start the instance and configure the new storage to be swap/swap file

Disk /dev/xvdg: 1073 MB, 1073741824 bytes

139 heads, 8 sectors/track, 1885 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfc4b3755

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdg1            2048     2097151     1047552   82  Linux swap / Solaris

ubuntu@iemijira:/$ free -h
             total       used       free     shared    buffers     cached
Mem:          992M       914M        78M        16K       2.2M        25M
-/+ buffers/cache:       886M       106M
Swap:         1.0G        12M       1.0G


Saturday, June 11, 2016

Wednesday, May 25, 2016

Resetting WordPress Account Password from Database


So, after months of hibernating my WordPress project, I forgot the "admin" password and lost the file where I stored my credential.

The solution - update the entry in the database!  Sour yet sweet!
UPDATE 'wp_users' SET 'user_pass'= MD5('<password>') WHERE 'user_login'='<username>';
Be sure to commit the change.

Sunday, April 10, 2016

Intel Compute Stick (STCK1A32WFC) - How to fix from botched Windows Update (WIN10 to WIN10)

The scenario: you got Intel Compute Stick plugged into your TV and connected to your WiFi/internet and did Windows update and suddenly it got stuck; then you hard reset and it's no longer working.  You tried clean/factory reset from the recovery and doesn't complete nor fixes the problem.



DO NOT PERFORM THE FOLLOWING:
  • Remove the default partitions
  • Reformat (later part)
  • Install another OS/Linux (unless you know what you are doing, it is possible though)
WHAT YOU NEED/NEED TO DO FIRST:
Note: 
  • OEM product keys works only with OEM ISO, same goes for HOME and PRO. Let me know if it is not the case because experiences and experiments told me so.
  • Torrent a Windows 10 CORE OEM - it should say "OEM"


NOW.  RECOVERY PROCESS:
  1. Once you have the Windows 10 OEM ISO, create a bootable USB drive from it using Rufus
  2. Plug your USB hub with the Windows 10 USB, keyboard/mouse
  3. Bootup ICS to Recovery Mode and go to Command Prompt (just look for it under Advance, I think)
  4. Go to the drive letter of your Windows 10 USB (probably D, E, F, G, etc.) and do a "dir" command.  You should be setup.exe.  Run it.
  5. Just follow the prompt until you reach "Advance" to install Windows 10.
  6. Select this and when you get the option on the disk - install it on the biggest partition you see.  It will rename the existing "Windows" folder to "Windows.old" where you will recover the product key using the tools mentioned above - how? Just go figure after the successful installation of this new Windows 10.  The OEM build by the way should be 10240.
  7. After a successful install run the product key recovery tools and use it to activate Windows 10 by changing the product key.  It should accept and activate.  Connect ICS to your WiFi. :)
  8. Install ICS graphics and other drivers - manually or by Windows Update.  You should also see a new build being download since 10240 is old.
  9. Make a backup of the product key and "Windows.old" folder for future reference and delete it to recover space.
  10. Look for Backup/Recovery in Control Panel - create a backup image and store it somewhere.
  11. Once the steps are performed, YOU'RE GOOD TO GO!

Tuesday, March 1, 2016

qwikLAB - zero to AWSomeness!

No idea on Amazon Web Services, cloud computing, and their offerings? Here is a hands-on training for you!



qwikLABS

Read or watch the tutorial and do it on an actual environment - free!

Saturday, February 27, 2016

My First AWS EC2

There isn't much to say except this is my first time to launch EC2 T2.Micro instance using Free Tier!


Sunday, February 21, 2016

PHP + AD on SSL = Password Reset

Problem: 
You're getting called just to reset their F###!## password on a system that authenticates on Active Directory

Solution: 

Self service password reset/management webpage

Setup:

PHP + Apache connecting to AD via SSL. I used XAMPP, Windows 2008 R2 + AD and CA to accomplish this.

Code:

[02/23/2016] - To follow... working but still in progress. References will be added continuously.

For now, I will summarize the steps needed with the assumption of codes already available.

  1. Windows 2008 with AD and CA.
  2. Web server with PHP. Apache, IIS, others as long as it works with PHP with modules enabled as mentioned above.
  3. Issued certificate from CA and converted for OpenSSL.
I did not count days to accomplish this task but the opened browser tabs containing articles and put it all together. :)

[02/25/2015] - The codes

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Password Reset</title>
</head>
<body>
<img src="logo.jpg" width="166" height="109" alt=""/><br />
PASSWORD RESET FORM<br /><br />
<div class="form1" id="form1">
<form action="reset.php" method="post">
User:<br />
    <input type="text" name="user"> <br />
    New password:<br />
<input type="text" name="password"> <br /><br />
    <input type="submit" name="submit" id="submit" value="Submit" />
<input type="reset" />
</form>
</div>
</body>
</html>

reset.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Password Reset!</title>
</head>
<body>
<?php
$ldaphost = "ldaps://poc.domain.net"; 
$ldapport = 389;
$ldaprdn  = 'domain\administrator';
$ldappass = 'Admin123';
$ldapconn = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($ldapconn) {
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
$pwdtxt = $_POST['password'];
$newPassword = '"' . $pwdtxt . '"';
$newPass = iconv( 'UTF-8', 'UTF-16LE', $newPassword );
//$ldaprecord["unicodepwd"] = $newPassw;
$userdata["unicodepwd"] = $newPass;

// change password

$userDn = "CN=" . $_POST['user'] . ",CN=Users,DC=domain,DC=net";
$result = ldap_mod_replace($ldapconn, $userDn, $userdata);
if ($result) {
echo "Password modified!";
} else {
echo "There was a problem!";
}
}
echo "<br /><br />";
echo $userDn;
?>
</body>
</html>

References:
http://greg.cathell.net/php_ldap_ssl.html
http://forums.devshed.com/ldap-programming-76/
https://www.novell.com/coolsolutions/tip/5838.html
http://php.net/manual/en/function.ldap-start-tls.php
https://www.exchangecore.com/blog/how-use-ldap-active-directory-authentication-php/
http://technology.mattrude.com/2010/11/ldap-php-change-password-webpage/
https://directory.apache.org/apacheds/basic-ug/3.3-enabling-ssl.html