terça-feira, 28 de janeiro de 2020

Java Obfuscate Properties

Hi there how many times we have fuckin stupid commentaries of , hey the code has a password... bullshit you can always get the password... Ok lets encrypt, obfuscate , anything In last days i just get an example of very well writen lib "refcodes-configuration-ext-obfuscation" that can read / save a java properties file, and can read / write encripted data. An example: Let's save a property to an file:

package org.ofusc.prop;

import org.refcodes.configuration.PropertiesSugar;
import org.refcodes.configuration.ResourceProperties.ResourcePropertiesBuilder;
import org.refcodes.configuration.ext.obfuscation.ObfuscationResourceProperties.ObfuscationResourcePropertiesBuilder;
import org.refcodes.configuration.ext.obfuscation.ObfuscationResourcePropertiesBuilderDecorator;

public class testPropOfusc {

 public static void main(String[] args) {

  try {
   new testPropOfusc().run();
  } catch (Exception e) {
   e.printStackTrace();
  }

 }

 private void run() throws Exception {

  ResourcePropertiesBuilder properties = PropertiesSugar.seekFromJavaProperties(
    "test.properties");

  String theSecret = "1234567890";
  properties.put("secret", "encrypt:" + theSecret);

 }
}

Let 's see the props file:

secret=decrypt\:jNckuOrrv/IYLQ\=\=


cool it saved some shit that is encripted somehow. Letś read it now:

  ResourcePropertiesBuilder properties = PropertiesSugar.seekFromJavaProperties(
    "test.properties");

  ObfuscationResourcePropertiesBuilder theObfuscated = new ObfuscationResourcePropertiesBuilderDecorator(
    properties);
  String theValue = theObfuscated.get("secret");
  System.out.println(theValue);
Cool, it worked... Dont forget the mvn repo on pom.xml

    org.refcodes
    refcodes-configuration-ext-obfuscation
    2.0.0


bye,

quinta-feira, 9 de janeiro de 2020

Ubuntu 16, suspend with HDMI turn off sound

oh, my god after some crazy months, i finally discovered why ubuntu after a suspend, the sound did stop working
vi /etc/modprobe.d/alsa-base.conf
# add 
"options snd-hda-intel probe_mask=1"

# shiftzz

sudo reboot
and thats is why ? dont know... credits from https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1826868/comments/3

sábado, 1 de setembro de 2018

linux , some new issues

Hi, latelly i have been struggling with LINUX / my new ssd. The ssd has nothing wrong, but i can install ubuntu 16.06, always blocks on installation. I did discover that i have 3x issues: 1. the realtek wifi board was making a lot of errors and full the disk So i installed the ubuntu 14, and than change the grub:

sudo gedit /etc/default/grub
 put on GRUB_CMDLINE_LINUX_DEFAULT
      pci=nomsi,noaer 

2. realtek wifi signal AGAIN, the signal was very poor, already described on other post.
iwlist scan | egrep -i 'ssid|quality'
sudo modprobe -r rtl8723be
sudo modprobe rtl8723be ant_sel=1
iwlist scan | egrep -i 'ssid|quality'
echo "options rtl8723be ant_sel=1" | sudo tee /etc/modprobe.d/rtl8723-ant-sel.conf

3. sound than the sound stops working, i discover that only after suspend. Than after suspend the HDMI sound ports appears, and headphones disappears. Trick:

sudo gedit /etc/pulse/default.pa

 put on GRUB_CMDLINE_LINUX_DEFAULT

and comment the:

#load-module module-switch-on-port-available

uff

domingo, 12 de novembro de 2017

HP with wifi realtek

Hi, just bought a HP laptop, I unstalled the linux ubuntu 16.04 on it, and surprise, the wifi was extreme slow. Some tips that i spent about 2x weeks to discover: 1. turn off power save
sudo gedit /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
change wifi.powersave = 3
to 
wifi.powersave = 2
2. try to check what antenna shall use The laptop can have several antennas, check the best one.

sudo modprobe -rv rtl8723be
sudo modprobe -v rtl8723be ant_sel=2

sudo modprobe -rv rtl8723be
sudo modprobe -v rtl8723be ant_sel=1
If want to stay configured the best one, put:
echo "options rtl8723be ant_sel=1"  >  /etc/modprobe.d/rtl8723be.conf
or
echo "options rtl8723be ant_sel=1"  >  /etc/modprobe.d/rtl8723be.conf
3. some support commands

iwlist scan | egrep -i 'ssid|level'
sudo systemctl restart NetworkManager

https://askubuntu.com/questions/635625/how-do-i-get-a-realtek-rtl8723be-wireless-card-to-work https://askubuntu.com/questions/752850/hp-stream-11-late-2015-edition-r050sa-wifi-not-working-properly hope that helps more people. cheers

sexta-feira, 7 de outubro de 2016

install metatrader on ubuntu

Hi, Metatrader is a very well known software for FOREX trade. It's a windows program, but it's possible to run on Linux Ubuntu. Here it is the commands: - install a ppa for wine
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
- install wine
sudo apt-get install wine1.5
- download the metatrader .exe - NOW the TIP and trick on linux, some packages for https are need
sudo dpkg --add-architecture i386
sudo add-apt-repository ppa:wine/wine-builds
sudo apt-get update
sudo apt-get install --install-recommends winehq-devel
sudo apt-get install winetricks
sudo apt-get install p11-kit:i386
sudo apt-get install libp11-kit-gnome-keyring:i386
- now run the metatrader .exe using the wine executer bye

domingo, 24 de janeiro de 2016

blogspot : how to make code syntax hilight in a blog

Hi,
this shows a simple way to make code syntax highlighter on blogger.com.

on blog administration, goto :

1. template
2. edit html button
3. before the head put :










Than when you need to put a source example make:


all code here

python, download all files from a site

Hi ,
will not be cool to download all file type from a site, just to not delay to much time to do it.

There are some challenges to do it with Python:

1. how to accept cookies (cookiejar)
2. how to decode a site into elements (BeautifulSoup)


Here is the code:


"""
downloadAllPdfs.py
    Downloads all the pdf on the supplied URL, and saves them to the
    specified output file ("/test/" by default)

Usage:
    python downloadAllPdfs.py http://example.com/ [output]
"""

from bs4 import BeautifulSoup 
import urllib.request as urllib2
import http.cookiejar
import sys

def _downloadFileFromServer(finalFileUri,outputpath):
    print("==> _downloadFileFromServer %s" % finalFileUri )
    filename=finalFileUri.rsplit('/', 1)

    cj = http.cookiejar.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    page = opener.open(finalFileUri)
    data = page.read()
    page.close()
    opener.close()

    print("==> _downloadFileFromServer %s" % outputpath+filename[1] )

    FILE = open(outputpath+filename[1], "wb")
    FILE.write(data)
    FILE.close()

def _downloadFolder(url,outputpath):
    print("\tdownload %s" % url )
    cj = http.cookiejar.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    
    page = opener.open(url)
    soup = BeautifulSoup(page)
    #print (soup.prettify(None,"minimal"))
    
    for lnk in soup.findAll("a"):
        print ("\t\tcheck lnk %s" % lnk)
        
        
        if lnk.has_attr('href'):
            filename = lnk["href"]
        else:
            continue
        
        
        if filename is None:
            continue


        if filename.find(".pdf") >=0 or filename.find(".zip") >=0  :
            finalFile=filename
            if filename.find("http://")<0 :
                finalFile=url + filename
            _downloadFileFromServer(finalFile,outputpath)
            
    print("DONE download %s" % url )
    print("" )
            

def main():
    print ("==init==")
    url=sys.argv[1]
    outputpath=sys.argv[2]+"\\"
    print ("download from %s"%url)
    print ("to %s"%outputpath)

    _downloadFolder(url,outputpath)
    print ("==done==")


if __name__ == "__main__":
    main()



Raspberry 2 - part 3- blink leds with Python

Hi,
this tutorial today, will show how to use the raspberry and the linux installed, to control the GPIO with a simple Python script.

So the ideia, is to use the GPIO 17 and 18, to swith on and off, 2x LED´s.
Each LEd is connected to a GPIO with a serial resistance (1k) to limit the output current.
After a resistance is the LED.

Before connect the GPI check the pin on the raspberry site.
The GPIO of my raspberry is:


The schematic for the connections shall be:


The code of script is:

'''
Created on 23/01/2016

@author: tecbea
'''
# import gpio
import RPi.GPIO as GPIO
# import time 
import time


def _ledLoop (io,num,sleep):
    for num in range(1,num):
        print "io %d on" % io
        GPIO.output(io,GPIO.HIGH)
        time.sleep(sleep)
        print "io %d off" % io
        GPIO.output(io,GPIO.LOW)
        time.sleep(sleep)

def main():
    print ("==init==")

    # set mode on gpio 18
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    # output mode
    GPIO.setup(17,GPIO.OUT)
    GPIO.setup(18,GPIO.OUT)
    
    _ledLoop(17,10,0.5);
    _ledLoop(18,10,0.5);
    _ledLoop(17,20,0.1);   
    _ledLoop(18,20,0.1);   

# ###############################
if __name__ == "__main__":
    main()


best

sexta-feira, 22 de janeiro de 2016

Wildfly, Eclipse Luna, Hot deploy

Hi,

Is there a way yo have a maven projet in eclipse, and make auto deploy of objects changes and html changes ?

Yes Eclipse can do it, i still did not put to work when a class has a new method or attribute.

1. with eclipse luna
2. with wildfly 8
3. a maven project
4. make "run as " , run on server, choose wildfly 8
5. on servers -> start  the server and deploy the project
6. on servers, dbl click on the server, it will appear the server configuration

On "Application reload behaviour"
click on intercept hot code and put on the edit box "\.jar$|\.class$"

On "publishing"
choose automatic publish after a build event

7. If you want to pass parameters to Wildfly startup, click on open launch configuration , example

 -Dproperties.file=/hmi.properties

best

terça-feira, 5 de janeiro de 2016

Redis performance with JEDIS - II


7. And continue the benchs for publish - subscribe :

 I was not able to do the best in term of tunning.
Seems that when subscribers are slow i usually have "conn fail" and events are dropped. Remember this is mem database .


pubNumber SubsTotal OpsTime msOp/sec
155000002955169204.7377
1510000004570218818.3807





1105000004408113430.127
11010000007478133725.5951





120500000747966853.85747
12010000001271178672.01636


8.



segunda-feira, 4 de janeiro de 2016

Install Linux on Raspberry PI2 - part 2 - setup static ip address


Hi,

as described on Part 1, after flashing the sd card with the Raspberrian Jessie, the pi is ready to start with configurations.

After a boot, the first thing, is what is the ipaddress of the eth0; well it comes with default dhcp configuration.

After some inspection, i found that the /etc/networks/interfaces is not working as older linux.

To configure with a static ip address make this:

1. goto /etc/network/interfaces, and configure ip interface mode for eth0

iface eth0 inet manual

2. the static ip configuration is done on /etc/dhcpcd.conf

add to the end of the file

interface eth0
static ip_address=192.168.0.1/24
static routers=192.168.0.254

With this configuration the pi will be with ipv4 192.168.0.1
Configure your PC with ipv4 : 192.168.0.2, with netmask 255.255.255.0

Than test the conection :

ping 192.168.0.1

And static ip is done.
After this download a ssh like putty or excelent mobaxterm.

The login credentials will be :

mode : ssh2
user :  pi
password : raspberry


That´s it.

best

Java Obfuscate Properties

Hi there how many times we have fuckin stupid commentaries of , hey the code has a password... bullshit you can always get the password... ...