Skip to content

Instantly share code, notes, and snippets.

View pastranastevenaz's full-sized avatar
🎯
Focusing

Steven Antonio pastranastevenaz

🎯
Focusing
View GitHub Profile
@pastranastevenaz
pastranastevenaz / wordpress-ishome.php
Last active May 9, 2019 06:02
Wordpress conditional for if homepage
<?php if (is_front_page() ) : ?>
<h1>Hello World</h1>
<?php endif; ?>
@pastranastevenaz
pastranastevenaz / table-to-csv.php
Created April 8, 2019 20:45
Export a database table to a csv and prompt for download
<?php
// The name of the table
$db_record = '';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
$hostname = "";
@pastranastevenaz
pastranastevenaz / npm-global.sh
Created March 30, 2019 19:18
configure npm to use a differnt global install directory, in order to bypass sudo requirements in global install
#Make a directory for global installations:
mkdir ~/.npm-global
#Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
# Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
# Back on the command line, update your system variables:
@pastranastevenaz
pastranastevenaz / getmalware.php
Created February 21, 2019 01:30
Scan site for malware
<?php
public function getmalwaredata($s){
$movedSubstring = "301 Moved";
$url = 'www.' . $s;
$ch = curl_init();
// Check for iframes
$iframe = shell_exec("curl -s -X GET '{$url}' | grep iframe");
$iframeArray = explode(PHP_EOL, $iframe, -1);
@pastranastevenaz
pastranastevenaz / dnsdata.php
Created February 19, 2019 22:33
Query the DNS of a domain passed to this function. Returns an array of all the DNS info, A, MX, TXT, and NS records
<?php
public function getdnsdata( $x ){
$aRecords = shell_exec("dig +short {$x} a");
$aArray = explode(PHP_EOL, $aRecords,1);
$mxRecords = shell_exec("dig +short {$x} mx");
$mxArray = explode(PHP_EOL, $mxRecords, -1);
$txtRecords = shell_exec("dig +short {$x} txt");
$txtArray = explode(PHP_EOL, $txtRecords, -1);
@pastranastevenaz
pastranastevenaz / nextlineedit.sh
Last active February 4, 2019 18:45
find a string and append change the next line
sed -i "s|export default {|export default {\nprops:['darkTheme'],|g" testfile.vue
sed -i "s|<div class="notification is-dark">|<div v-bind:class="{'is-dark': !darkTheme}" class="notification has-text-centered">|g" testfile.vue
@pastranastevenaz
pastranastevenaz / fileschanged.php
Created January 30, 2019 06:38
Find files that show new or changed. The example uses PHP for the var/www directory
<html>
<head></head>
<body>
<h2>Last 24</h2>
<?php
echo shell_exec("find /var/www -type f -mtime -1;");
?>
<h2>Last 48</h2>
<?php
echo shell_exec("find /var/www -type f -mtime -2;");
@pastranastevenaz
pastranastevenaz / selector.vue
Created January 15, 2019 19:56
VueJS Dynamic Selector Example
<select v-model="supervisorSelected">
<option v-for="sup in supervisors" v-bind:value="sup">
{{ sup.name }}
</option>
</select>
@pastranastevenaz
pastranastevenaz / clean.js
Created January 10, 2019 22:23
Clean a URL with Javascript
cleanUrl: function (dirtyURL){
var a = dirtyURL.toLowerCase();
if (a.startsWith("http") ) {
a = a.split('/')[2];
a = a
.replace('https', '')
.replace('http', '')
.replace('www.', '')
.replace('://', '')
.replace(/\/$/, '')
@pastranastevenaz
pastranastevenaz / lookup.php
Last active February 19, 2019 22:32
SSL Lookup Script. Queries a site's SSL information using the openSSL tool in Linux
<?php
public function getssldata( $d ){
$domain = $d;
$url = "www." . $domain;
$ip = gethostbyname($url);
$commonName = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -subject | sed -e 's/.*CN=\*.//'");
$sans = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -text | grep DNS | sed -e 's/DNS://g'");
$expireDate = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed -e s#notAfter=##");
$issuer = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -issuer | sed -e 's/.*CN=//' -e 's/\/OU.*//'");
$signatureAlgorith = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -text | grep 'Signature Algorithm' | head -1 | sed -e 's/.*m://'");