Analogman Tech Blog

Analogman Tech News Blog

Stop SQL Injection from .htaccess

# Enable rewrite engine RewriteEngine On # Block suspicious request methods RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC] RewriteRule ^(.*)$ — [F,L] # Block WP timthumb hack RewriteCond %{REQUEST_URI} (timthumb\.php|phpthumb\.php|thumb\.php|thumbs\.php) [NC] RewriteRule . — [S=1] # Block suspicious user agents and requests RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (<|>|’|%0A|%0D|%27|%3C|%3E|%00) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (;|<|>|’|”|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR] RewriteCond %{THE_REQUEST} \?\ HTTP/ Read more about Stop SQL Injection from .htaccess[…]

How install PHP Phalcon Framework on CentOS 6-7

THE STEPS Updated all repo centos sudo yum update Then I installed the proper php devel pacakage along with other depencies that were needed for the install by using the command yum — enablerepo=remi,remi-php54 install php-devel Then I had to also install the gcc package from yum with the following sudo yum install gcc Then Read more about How install PHP Phalcon Framework on CentOS 6-7[…]

How To Send Email From Localhost Using PHP Xampp Windows

We can send mail from our localhost using some mail configuration by XAMPP/LAMP/WAMP server, First we need to enable php_openssl php extensions from php.ini file.I am using GMAIL SMTP server to send mail from localhost and sendmail package,It is a mail transport agent which can be found in php.ini file.The sendmail package is inbuilt in Read more about How To Send Email From Localhost Using PHP Xampp Windows[…]

Enable Mod_Rewrite Module In Apache in Xampp Windows

wamp/xampp mod_rewrite is an Apache web server module which is used to rewrite a URL at the server level.The mod_rewrite module normally uses a rule-based rewriting engine to rewrite requested URLs based on PCRE regular-expression parser, By defaults mod_rewrite maps a URL to a filesystem path.It allow you to rewrite URL based on server variables, Read more about Enable Mod_Rewrite Module In Apache in Xampp Windows[…]

Eclipse “Initializing Java Tooling” hangs Freeze Debug Start

Sometimes using SpringSource Tool Suite (STS) e.g. which is based on Eclipse – startup hangs on various operations:Initializing Java Tooling Repository registry initialization STS/Eclipse does not seem to respond to anything – the UI freezes and that’s it! I’ve had this on several occassions with no apparent cause on my part. Usually it has something Read more about Eclipse “Initializing Java Tooling” hangs Freeze Debug Start[…]

Java Luhn algorithm Card Number Generator

Recently I came to know that Credit Card numbers are not random and passes Luhn Algorithm test. Java Credit Card Validation Any credit card number should pass following test: From the rightmost digit, we should double every second digit. If the double is greater than 9, then add the both digits so that final number Read more about Java Luhn algorithm Card Number Generator[…]

PHP excel Extract All Content Data to Txt

build : SpreadsheetReader.php <?php /** * Main class for spreadsheet reading * * @version 0.5.10 * @author Martins Pilsetnieks */ class SpreadsheetReader implements SeekableIterator, Countable { const TYPE_XLSX = ‘XLSX’; const TYPE_XLS = ‘XLS’; const TYPE_CSV = ‘CSV’; const TYPE_ODS = ‘ODS’; private $Options = array( ‘Delimiter’ => ”, ‘Enclosure’ => ‘”‘ ); /** * Read more about PHP excel Extract All Content Data to Txt[…]

PHP PDF convert to txt extract Content txt Example

class PDF2Text { // Some settings var $multibyte = 4; // Use setUnicode(TRUE|FALSE) var $convertquotes = ENT_QUOTES; // ENT_COMPAT (double-quotes), ENT_QUOTES (Both), ENT_NOQUOTES (None) var $showprogress = true; // TRUE if you have problems with time-out // Variables var $filename = ”; var $decodedtext = ”; function setFilename($filename) { // Reset $this->decodedtext = ”; $this->filename Read more about PHP PDF convert to txt extract Content txt Example[…]

PHP Doc or Docx Word File to TXT extract Content Example

class Doc2Txt { private $filename; public function __construct($filePath) { $this->filename = $filePath; } private function read_doc() { $fileHandle = fopen($this->filename, “r”); $line = @fread($fileHandle, filesize($this->filename)); $lines = explode(chr(0x0D),$line); $outtext = “”; foreach($lines as $thisline) { $pos = strpos($thisline, chr(0x00)); if (($pos !== FALSE)||(strlen($thisline)==0)) { } else { $outtext .= $thisline.” “; } } $outtext = Read more about PHP Doc or Docx Word File to TXT extract Content Example[…]

PHP extract PPTX or PPT powerpoint files format to TXT Example

$zip_handle = new ZipArchive; $output_text = “”; if(true === $zip_handle->open(WWW_ROOT.’files/Dokumen/’.$physic_filename)) { $slide_number = 1; //loop through slide files while(($xml_index = $zip_handle->locateName(“ppt/slides/slide”.$slide_number.”.xml”)) !== false){ $xml_datas = $zip_handle->getFromIndex($xml_index); $xml_handle = DOMDocument::loadXML($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING); $output_text .= strip_tags($xml_handle->saveXML()); $slide_number++; } if($slide_number == 1){ $output_text .=””; } $zip_handle->close(); }else{ $output_text .=””; }

Mirroring Screen Android ke Desktop menggunakan Scrcpy

Mirroring Screen Android ke Desktop menggunakan Scrcpy. Beberapa orang kadang jika sudah di depan PC atau laptop dan sudah fokus ke layar jadi jarang banget buat buka smartphone. Namun adakalanya kita juga masih butuh smartphone misalnya untuk memeriksa kode OTP dll. Nah daripada ribet bolak balik cek smartphone, lebih baik kita mirror screen Android kita Read more about Mirroring Screen Android ke Desktop menggunakan Scrcpy[…]

How to keep processes running after ending ssh session

You should look for modern alternatives like tmux. tmux is superior to screen for many reasons, here are just some examples: Windows can be moved between session and even linked to multiple sessions Windows can be split horizontally and vertically into panes Support for UTF-8 and 256 colour terminals Sessions can be controlled from the Read more about How to keep processes running after ending ssh session[…]

dynamic category and question

now i have chalenge for create dynamic category and question   String totalCat = (String) request.getAttribute(“totalcat”); Integer totalCategory = Integer.parseInt(totalCat); System.out.println(“total category:” + totalCategory); for (int countCat = 0; countCat < totalCategory; countCat++) { String Category = (String) request.getAttribute(“category” + countCat); System.out.println(“categoryid:” + Category); String totalQuestion = (String) request.getAttribute(“totalquest” + Category); System.out.println(“totalQuestion:” + totalQuestion); Integer Read more about dynamic category and question[…]

Could not initialize class sun.awt.X11GraphicsEnvironment – Exception Type java.lang.NoClassDefFoundError

today i have message error in my page web application about : java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment java.lang.Class.forName0(Native Method) java.lang.Class.forName(Class.java:264) java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82) sun.awt.X11FontManager.isHeadless(X11FontManager.java:509) sun.awt.X11FontManager.getFileNameFromPlatformName(X11FontManager.java:189) sun.font.SunFontManager.initCompositeFonts(SunFontManager.java:3481) sun.font.SunFontManager.access$700(SunFontManager.java:65) sun.font.SunFontManager$2.run(SunFontManager.java:545) java.security.AccessController.doPrivileged(Native Method) sun.font.SunFontManager.<init>(SunFontManager.java:376) sun.awt.FcFontManager.<init>(FcFontManager.java:35) sun.awt.X11FontManager.<init>(X11FontManager.java:57) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:423) java.lang.Class.newInstance(Class.java:442) sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83) java.security.AccessController.doPrivileged(Native Method) sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74) java.awt.Font.getFont2D(Font.java:491) java.awt.Font.canDisplayUpTo(Font.java:2060) java.awt.font.TextLayout.singleFont(TextLayout.java:470) java.awt.font.TextLayout.<init>(TextLayout.java:531) org.apache.poi.xssf.usermodel.helpers.ColumnHelper.getColumnWidth(ColumnHelper.java:326) org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:337) My application running in Centos 6.8. Read more about Could not initialize class sun.awt.X11GraphicsEnvironment – Exception Type java.lang.NoClassDefFoundError[…]

Migration Redmine (Bitnami) to New Server

Now, i have case to migration redmine to new server  (at Centos 6.5), and this is my notes. 1. Dump database mysql on last server and copy folder /contents 2. Install your redmine bitnami in new server. 3. Add path ruby to new server at .bashrc in /root PATH=”$PATH:/opt/redmine/ruby/bin:/opt/redmine/git/bin:/opt/redmine/perl/bin::/opt/redmine/apache2/bin::/opt/redmine/subversion/bin” and restart to run the path. 4. Read more about Migration Redmine (Bitnami) to New Server[…]

Building Dynamic Favicon with JavaScript

You may probably notice that many social networks and modern web applications have dynamic favicons. If you are using Bamboo for deploying your projects, you may also catch the percentage based favicon and if you succeed, the favicon is replaced with success icon. First, let’s handle the favicon and then we will make it dynamic. Read more about Building Dynamic Favicon with JavaScript[…]

WebRTC Live Video Stream Broadcasting One-To-Many and Watching with RTMP and HLS

With the first version on Ant Media Server, developers can make users broadcast live video from their browser with WebRTC and live stream can be distributed to many with RTMP and HLS, thanks to WebRTC Adapter. In other words, users can broadcast live video from browsers as they do with a flash plugin, fortunately, this Read more about WebRTC Live Video Stream Broadcasting One-To-Many and Watching with RTMP and HLS[…]

PHP seo_friendly_url

function seo_friendly_url($string){ $string = str_replace(array(‘[\’, \’]’), ”, $string); $string = preg_replace(‘/\[.*\]/U’, ”, $string); $string = preg_replace(‘/&(amp;)?#?[a-z0-9]+;/i’, ‘-‘, $string); $string = htmlentities($string, ENT_COMPAT, ‘utf-8’); $string = preg_replace(‘/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i’, ‘\\1’, $string ); $string = preg_replace(array(‘/[^a-z0-9]/i’, ‘/[-]+/’) , ‘-‘, $string); return strtolower(trim($string, ‘-‘)); }

Upgrading simple shells to fully interactive TTYs

Table of Contents Generating reverse shell commands Method 1: Python pty module Method 2: Using socat Method 3: Upgrading from netcat with magic tl;dr cheatsheet     Every pentester knows that amazing feeling when they catch a reverse shell with netcat and see that oh-so-satisfying verbose netcat message followed by output from id. And if Read more about Upgrading simple shells to fully interactive TTYs[…]

Lua obfuscator

local thing = [[ — Put script here ]] local encoded = thing:gsub(“.”, function(bb) return “\\” .. bb:byte() end) or thing .. “\”” print(encoded) print(“Put the above encoded string into the loadstring below between the quotation marks for the obfuscated scrippts.”) print’loadstring(“”)()’

Cara print ke printer pos langsung dari browser

Urusan print meng-print memang sebenarnya lebih ke urusan aplikasi desktop, nah terus bagaimana programmer web based seperti saya ? beberapa project saya kebetulan mengharuskan saya untuk bisa melakukan printing. Sebenarnya ini tidak terlalu sulit, menggunakan fungsi JS window.print() sudah bisa, namun fungsi window.print() tidak begitu memberikan hasil yang baik terutama jika menggunakan printer jenis pos Read more about Cara print ke printer pos langsung dari browser[…]

DB2 REORG TABLE expected include JOIN error solution

Unfortunately, REORG TABLE is not a normal SQL statement. It is not intended to be used by normal SQL users and therefor cannot be issued just like a  normal SQL statement. Here’s what you get from DB2 if you inspect myGlorpSession accessor executeSQLString: ‘REORG TABLE schema.tablename’: AbtError:  rc=-1 for ‘42601’ in an AbtIbmCliCSDatabaseConnection at (24.04.2013 Read more about DB2 REORG TABLE expected include JOIN error solution[…]

SQL0104N when a REORG reorg table command is issued from a CLI application

Troubleshooting Problem When a reorg table command is issued from a CLI application against a DB2 database server, the application fails with SQL0104N. Symptom For example: Similar entries may be seen in a CLI trace: SQLGetDiagRecW( fHandleType=SQL_HANDLE_STMT, hHandle=1:1, iRecNumber=1, pszSqlState=&02f0f684, pfNativeError=&02f0f750, pszErrorMsg=&03672b98, cbErrorMsgMax=512, pcbErrorMsg=&02f0f74c ) —> Time elapsed – +9.000000E-006 seconds ( iRowNumber=-1, iColumnNumber=-2 ) Read more about SQL0104N when a REORG reorg table command is issued from a CLI application[…]

How to alter an identity column as generated by default to generated always

1 – First Step Drop the propriety identity db2 alter table <table_name> alter column <column_name> drop identity 2 – Second step Create the propriety identity again, now as generated always db2 alter table <table_name> alter column <column_name> set generated always as identity (start with <max(column_identity_name)>) Example: db2 “alter table identity alter column col3 set generated Read more about How to alter an identity column as generated by default to generated always[…]

Creating a Simple Rss Application in Android (V2)

Starting with Android 3.0 and higher when trying to perform a network operation from the UI thread, the NetworkOnMainThreadException is thrown. The previous example did not address this issue. Why? Well… the tutorial didn’t have the purpose to present a stable application from all points of view, its main intention was to show how to Read more about Creating a Simple Rss Application in Android (V2)[…]