OpenWrt webcam

Install in OpenWrt:
kmod-video-uvc
mjpg-streamer
luci-app-mjpg-streamer
//refresh
//Go to: services/mpg-streamer
//Set it to: enabled
//That will be all
//Optional: Setup security and other parameters

A still image will be available on:
http://192.168.130.1:8080/?action=stream
The stream will be available on:
http://192.168.130.1:8080/?action=snapshot

//—————————-
//Optional:
//If you wanna go further and send a still image directly from the router to some site:

//download it with:

curl -o /www/webcam/images/image.jpg http://192.168.130.1:8080/?action=snapshot
//upload it to your server with:
curl -F "upimage=@/www/webcam/images/image.jpg" http://yourserver.com/upload.php

//to get the code executed each x seconds, set a cron job, or run a command like this:

while true; do date ; curl -o /www/webcam/images/image.jpg http://192.168.130.1:8080/?action=snapshot ; curl -F "upimage=@/www/webcam/images/image.jpg" http://yourserver.com/upload.php ; sleep 10; done

The server PHP code to save the images:

$source = $_FILES["upimage"]["tmp_name"];
$destination = "image.jpg";
echo move_uploaded_file($source, $destination) ? "OK" : "ERROR";

//To see the image you go to url below
http://yourserver.com/image.jpg
//Refresh to get a new one

//Or you can add a simple html/javascript code that does the trick for you:

function refreshIt(element) {
setTimeout(function() {
element.src = element.src.split('?')[0] + '?' + new Date().getTime();
refreshIt(element);
}, 10000); // refresh every 10 seg
}

<img=”” src=”/image.jpg” name=”myCam” onload=”refreshIt(this)”>

References:

https://openwrt.org/docs/guide-user/hardware/video/usb.video
https://www.you tube.com/watch?v=KlfS-oO_2Sw
https://stackoverflow.com/questions/8459896/auto-update-image/8459978

AC.


Posted in Linux | Tagged , | Comments Off on OpenWrt webcam

WordPress Mysql Migration

Magic formula:

Most free plugin to “backup” charge your migration, when is a matter of running few lines of code on your database…

UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl.com', 'https://newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldurl.com','https://newurl.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurl.com', 'https://newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurl.com','https://newurl.com');
UPDATE wp_revslider_slides SET params = replace(params, 'oldurl.com', 'newurl.com');
// last line only needed if you use revslider, a lot of themes do now...

AC.

Posted in Uncategorized | Tagged , | Comments Off on WordPress Mysql Migration

WordPress Auto Lazy Loading

New wordpress (since?) Has an automatically lazy loading for images.. if that broke your site, you can disable it with the following code:
add_filter( 'wp_lazy_loading_enabled', '__return_false' );

AC.

Posted in Uncategorized | Tagged | Comments Off on WordPress Auto Lazy Loading

Monero v0.15.0.0 Hacked Client

—–> WARNING <—–
https://github.com/monero-project/monero/issues/6151
https://www.reddit.com/r/Monero/comments/dyfozs/security_warning_cli_binaries_available_on/

—–> ok <—– (matching hash from https://web.getmonero.org/downloads/hashes.txt)
monero-win-x64-v0.15.0.0.zip 72.14 MB
6b72b3836d179eb517154bbcb8e2119b168ae9d1054866a438aaeab9521f795f

monero-wallet-cli.exe 37.06 MB
54241b4e7dec43a44e81f4ad65741c937e5ef6b16c69552446bb92f902593e12

—–> bad <—– (unknown version retrieved from official site!!)
monero-wallet-cli.exe is modified, and monero-gen-trusted-multisig.exe is missing (to make it look as the same size?)
monero-win-x64-v0.15.0.0.zip 73.61 MB
179f157683bb0bb1b6c92c009920ad15a372cc0439d970b960447e18de108dad

monero-wallet-cli.exe 65.14 MB
963c1dfc86ff0e40cee176986ef9f2ce24fda53936c16f226c7387e1a3d67f74

Posted in Cryptocurrency | Tagged | Comments Off on Monero v0.15.0.0 Hacked Client

Clear opcache in PHP

If you are working on a shared environment and deleted PHP files keep around, check how to clear empty the cache…
In this case we found the server used “opcache” so with the function opcache_reset() we can get rid of the cache…

If you don’t have shell access, simply create a PHP file like this: clearcache.php
And add this code:

opcache_reset();

Run it! and you are ready 🙂

References:
https://www.php.net/manual/en/function.opcache-reset.php

AC

Posted in Linux, Medium Technical | Tagged , , , , , | Comments Off on Clear opcache in PHP

One Click Monero Win Node

# One Click Monero Win Node

#1 – download monero core + monero blockchain
https://getmonero.org/downloads/
https://downloads.getmonero.org/cli/win64
https://downloads.getmonero.org/blockchain.raw

#2 – import blockchain on custom dir, guard-against-pwnage=verify [only run with a trusted blockchain.raw]
monero-blockchain-import –data-dir x:\Monero\ –guard-against-pwnage 0 –input-file blockchain.raw

#3 – run on custom ip, remember open firewall [change port/config firewall]
monerod –data-dir x:\Monero\ –rpc-bind-ip 123.123.123.123 –rpc-bind-port 18080 –restricted-rpc –confirm-external-bind

#4 – start as a service, [use a custom restricted access user]
?

#EOF

Posted in Basic Technical, Cryptocurrency | Comments Off on One Click Monero Win Node

Android APK Modification

An APK file is a ZIP file with the files inside with certain structure so it can serve as installer.
So for a basic modification, you can just rename the file to “.ZIP” extract the files and do whatever you want and then archive it again as a zip and rename back to APK.
If you preserve the structure, it should work, and in that way you can modify some things…

If you are looking for getting into the code you will need to decompile the file with some kind of tool, for this case I used “Apktool” that is an Android decompiler.
Then you can take a look inside (some of*) the code, modify and recompile it. Taking note that Android installers need to be signed so it can be installed without hassle, and for that will use “jarsigner”.

How?
#prerequisites
#install java sdk, install apk tool

#disassemble
apktool d someapp.apk -o someapp_disassembled

#mod code
#use a editor (text,graphics,etc) to modify code files

#assemble
apktool b someapp_disassembled/ -o someapp_modded.apk

#create your own signature (this have to be done only one time)
keytool.exe -genkey -v -keystore my-release-keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 365

#sign
jarsigner.exe -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-keystore someapp_modded.apk alias_name

* Not all code will be decompiled, there are static libraries (“.so”,etc) and java files (“.jar” with “classes.dex”) that are not decompiled
So if you also need to step into the deep code…
For static “.so” libraries you will need a disassembler for the platform that is based the APK (usually ARM), in this case you can use IDA. (Use of IDA not covered on this post)
For “.jar” files you will need something like “dex2jar” that decompile the classes, and something to read the classes like “jd-gui”. (Use of these tools not covered on this post)
And as compilation of these files vary a lot, I recommend that if you want to change something on those files, just use a binary editing tool.

Notes:
Even if you can unarchive an APK and archive it back using a archive tool (Winrar,etc), it is not recommended, because not all the files inside an APK are archived on the same way. For example there are some resources that are archived without compression (stored), and doing that can cause the app to crash. (If it tries to read a file that it think that is not compress and it is) [Ex: “This file can not be opened as a file descriptor; it is probably compressed”]
Sign an APK with your custom signature could make it unable to be installed, you can replace the signature with the original and force android not to check the signature (And/or hot replace, “base.apk” on the device app folder) (Not covered on this post, take a look of “lucky patcher”)
Some apps share data with other apps of the same author, so again, if you are unable to install, try to delete (if is possible) any other application that might cause conflict. If the conflicting app cannot get installed because it is preloaded with the OS you can try to use tool to unistall system apps, or (recommend) switch the ROM to a custom one that does not have anything installed…
If something crash or does not work, does not install, etc. check the logs, their are your friend. (Ex. “ADB install” gives your the exact error [one one word] of why it fail)

Links:
Apktool: https://ibotpeaches.github.io/Apktool/install/
dex2jar: http://code.google.com/p/dex2jar/
jd-gui: http://jd.benow.ca/
IDA: https://www.hex-rays.com/products/ida/index.shtml

References:
? //TODO

AC.

Posted in Android, Medium Technical | Tagged , , , , , , , | Comments Off on Android APK Modification

Install certificate as System on Android

Use OpenSSL to transform the certificate to Android format (that is cert+info)
Extract ID using this command:
openssl.exe x509 -inform PEM -subject_hash -in charles.pem
It is the first line.
Name the certificate ID.0 (Ex: ce554431.0)
Extract certificate info using:
openssl.exe x509 -inform PEM -text -in charles.pem>somefile.txt
Then take the cert text and append the info and save it as ID.0

Certificate should be something like:
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
Certificate:
Data:
...

Then copy the certificate in the Android device to:
/system/etc/security/cacerts/

Or, if the certificate is already installed as user you can copy to system:
Copy it from:
/data/misc/user/0/cacerts-added/
To:
/system/etc/security/cacerts/

On both cases remember to set the permissions and user like the other certificates on the same folder, and that should be…

Notes:
– Some version of OpenSSL could give you a wrong ID, that will make the certificate not usable. In this case we used “OpenSSL 0.9.8h 28 May 2008 – GnuWin32”

AC.

Posted in Android, Security | Tagged , , , | Comments Off on Install certificate as System on Android

jQuery lazy image loading…

Just a speed up trick, if you have lot of images or big images, to allow the browser to render and show the page before load the images you can do a “lazy” loading, that means that you load a marker or empty images with HTML, and with JavaScript/jQuery you update the resources.

HTML:
<img src="/empty.png" data-src="http://domain.com/image.jpg" alt="" width="200" height="70" />

Script:
jQuery(document).ready(function(){
//Change lazy images per real
jQuery("img").each(function() {
var $this = jQuery(this);
var imgsrc = $this.attr('data-src');
if(imgsrc!=''){
$this.attr('src', imgsrc).removeAttr('data-src');
}
});
});

Note: to minimize the in screen time while the image is loading it is recommended to use progressive encode on the images… or a loader… or the combination of both…

AC.

Posted in Medium Technical | Tagged , , | Comments Off on jQuery lazy image loading…

jQuery Playground: The base of AJAX

A very simple trick…

HTML:
<img id="some-image" src="http://domain.com/image.jpg" alt="" width="200" height="70" />

Script:
var someimage = jQuery("img[id='some-image']");
jQuery.get( someimage.attr("src"), function( ) {
// Do something
});

This (way of client requests) is the base of  AJAX/XMLHttpRequest, in this case is just an image but it can be any kind resource (code, json, java, xml, html) and can be processed asynchronous by the browser on any way to do whatever you want (send data, get data, play with the DOM, etc)…

Note: as this code is written it could cause the resource to load 2 times, so if it is not intended just use another attribute into the img tag, or other variable to get the URL…
Also for simpler things use javascript directly… or jQuery only if you already loaded it for other things… but it senseless load a 100k library to run 2 lines of code, hehe…

AC.

Posted in Basic Technical | Tagged , , , | Comments Off on jQuery Playground: The base of AJAX