Skip to content

Instantly share code, notes, and snippets.

@MasterEx
MasterEx / grammateia-stats.pl
Created October 22, 2011 16:32
Perl script for printing stats for a given e-grammateia lesson
#!/usr/bin/env perl
# 22-10-2011 - Periklis Master_ex Ntanasis <[email protected]>
#
# Usage: grammateia-stats.pl <link-to-e-grammateia-page-with-lesson's-grades>
#
use Encode;
$egrmmateiapage = $ARGV[0];
@MasterEx
MasterEx / id.php
Created October 9, 2011 00:27
PHP - insert unique identifier to file - steganography
<?php
function sendfile($file,$identifier,$id_length) {
if (file_exists($file)) {
$filesize = filesize($file)+$id_length;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
@MasterEx
MasterEx / README.md
Created September 29, 2011 18:57
PHP function alters set of characters with the given one

This is a small function that removes the punctuation from a given string in Greek. I haven't added upper case letters or multitone letters (except one letter to show how it can be expanded to fit your needs).

This function is pretty useful when using uppercase functions in our templates, because having upper case letters with tones isn't pretty.

Besides that you can map any set of characters or strings with a given character/string and then use it to alter all the mapped elements with the given one.

@MasterEx
MasterEx / Code.java
Created August 26, 2011 16:07
A source code encoder and a demonstration using it with PHP as a proof of concept
package coder;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
@MasterEx
MasterEx / Coolphpobfuscator.java
Last active April 6, 2021 15:58
A PHP code obfuscator implemented in java as a proof of concept
package coolphpobfuscator;
import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
@MasterEx
MasterEx / README.md
Created August 11, 2011 11:05
ArchLinux broken package entries

Somehow my /var was corrupted and I lost some files from /var/pacman/local/.

The files were many so I decided to download all the descriptions with the following script.

The -f argument does the following:

Bypass file conflict checks and overwrite conflicting files. If the package that is about to be installed contains files that are

@MasterEx
MasterEx / README.md
Created August 10, 2011 02:04
PHP download file wrapper

In the example the directory that contains the script also contains the directory files.

In order to download a file with filename "file.txt" we should call the script like http://domainname/file.php?filename=file.txt .

If the file doesn't exist we will get a "FILE NOT FOUND" message, otherwise we will get the file.

This is a good practice in order to conceal our file true location.

<?php
/**
* Retrieve public ip with PHP cURL
*/
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://whatismyip.org/');
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
$public_ip = curl_exec($curl_handle);
<?php
$input = "this is my sample which is sorted and simple";
echo "Input: ".$input."<br/>";
foreach(explode(" ",$input) as $in)
{
if(isset($firstarray[strlen($in)][$in]))
$firstarray[strlen($in)][$in]++;
@MasterEx
MasterEx / conf.php
Created July 20, 2011 20:31
PHP - include global configuration variables to functions and classes
<?php
//way 1
$bla = "tralala";
//way 2
$GLOBALS["blabla"] = "yoohoo";
?>