Posts

Showing posts from November, 2017

Impacket-master - psexec for linux

I have an application that need to execute remote commands on Windows and linux. This app run in a CentOS server. It is easy to execute a remote on linux, but on Windows I had to search a good solution and I had find Impacket-master. To use this solution you have to follow this steps: Install python in your linux; Download this libraries; argparse-master - https://pypi.python.org/pypi/argparse   pyasn1 - https://pypi.python.org/pypi/pyasn1   pycrypto-2.6.1 - https://pypi.python.org/pypi/pycrypto Install Libraries; Unpack files: tar -vzxf pyasn1-0.1.9.tar.gz Install: python setup.py install  After this, install Ipacket-Master: python setup.py install You can find psexec.py in examples folder: impacket-master/examples These is a command line with an example: python psexec.py domain/user:password@server 'cmd /c "dir /s c:\"'

Windows - Open exe, bat and all other program files from your intranet

It is common to have a lot of shortcuts to our systems on the intranet. It is easy to publish web applications but it is hard to put together all desktops programs. To make easy this task you have to to 3 steps: 1 - Create a batch file and put this in a share which everybody has access; 2 - Add in your Windows desktops a registry file, this file will contain an URI definition that will make possible the workstations understand what to do with the instruction from html link. 3 - Create a link in your intranet, or create a HTML file with a link to test. 1 - Batch file: create a batch file like this example. for /F "tokens=2 delims=: " %%a in ("%1%") do ( rem this step will get the program from instruction set startProgram=%%a ) rem this step will replace / for \ set htmlProgram=%startProgram:/=\% start %startProgram% 2 - Windows registry: Create a .reg file with a text like this example. Windows Registry Editor Version 5.00 [HKEY...

Firebird - List last command from each connection

You can do this with this select: select  MON$SERVER_PID as PID, a.MON$REMOTE_ADDRESS as IP, a.MON$REMOTE_PROCESS as Program, MON$PAGE_READS as DiskRead, MON$PAGE_WRITES as DiskWriters, s.MON$SQL_TEXT as SQL from MON$ATTACHMENTS a, MON$IO_STATS i, MON$STATEMENTS s where  a.MON$STAT_ID = i.MON$STAT_ID  and a.MON$ATTACHMENT_ID = s.MON$ATTACHMENT_ID order by   MON$PAGE_READS desc

Active directory - Import data from CSV file

You can use the powershell script below to import data from a CSV file to your Active Directory. This example importa the department property from file. Import-Module ActiveDirectory $users = import-csv c:\temp\data.csv foreach ( $user in $ users ){ Set-ADUser $ user . samaccountname -Department $ user . department } CSV file example samaccountname,department username1,departament1

Windows - Install .NET using command line

Sometimes you need to install .NET 3.5 or 4 using the graphical interface and gets an error. For .NET 3 you can use this command, do not forget to change the path for your media folder. Dism /online /enable-feature /featurename:NetFx3 /All /Source:"f:\sources\sxs" /LimitAccess This is example to install .NET 4 online. DISM.exe /Online /enable-feature /featurename:NetFx4 /all Just change the parameters to install .NET 3.5 online or .NET 4 using media.

Openedge (Progress) - BI reads and writes (version 2)

We know that sometimes is hard to infentify who is making BI growing up. With the select below you can see the username, IP address and another informations about the process who is making BI bigger than the normal size. select     database() as Database,                u."_UserIO-Name" as 'User',                u."_UserIO-BiWrite" as 'Writes',                u."_UserIO-BIRead" as 'Reads',                c."_Connect-Time" as 'Connection date',                t."_Trans-txtime" as 'Transaction date',                t."_Trans-Duration" as 'Seconds',                c."_Connect-IPAddress" as 'IP',                c."_Connect-Pid" as 'PID OS...

Openedge (Progress) - List tables with more reads, inserts, updates and deletes since database start

With the script below you can get all this information. Just change the order by the get update, insert or delete instead reads. select top 10     database() as 'Database',       f."_File-Name" as 'Table',       t."_TableStat-read" as 'Read',       t."_TableStat-update" as 'Update',       t."_TableStat-create" as 'Insert',       t."_TableStat-delete" as 'Delete' from PUB."_TableStat" t, PUB."_File" f where f."_File-Number" = t."_tablestat-id" order by 3 desc

Linux - Extending a logical volume in a virtual machine running Red Hat or Cent OS whithout reboot

With the step by step below you can extend your logical volume without a reboot. First find your device ls /sys/class/scsi_device/ Than find your disk fdisk -l With this information you can scan the device to detect the new size: echo 1 > /sys/class/scsi_disk/ 0:0:0:0 /device/rescan echo 1 > /sys/block/ sda /device/rescan *Change 0:0:0: acoording to your scsi device and sda acoording your disk   fdisk -l to see your new size. Now you have to create a new partition: fdisk -l /dev/ sda    (change the disk acoording your necessity) Than create a new primary partition: fdisk /dev/ sda     Press p to print the partition table to identify the number of partitions. By default, there are 2: sda1 and sda2.     Press n to create a new primary partition.     Press p for primary.     Press 3 for the partition number, depending on the output of the partition table pri...

MySQL - List blocks

With this select you can see if there a block in your MySQL Database. SELECT     pl.id     ,pl.user     ,pl.state     ,it.trx_id     ,it.trx_mysql_thread_id     ,it.trx_query AS query     ,it.trx_id AS blocking_trx_id     ,it.trx_mysql_thread_id AS blocking_thread     ,it.trx_query AS blocking_query FROM information_schema.processlist AS pl INNER JOIN information_schema.innodb_trx AS it ON pl.id = it.trx_mysql_thread_id INNER JOIN information_schema.innodb_lock_waits AS ilw ON it.trx_id = ilw.requesting_trx_id         AND it.trx_id = ilw.blocking_trx_id

My software - PDFSignatureTool

Image
I have had a necessity to sign a lot of PDFs files with certificates, especially A3. To turn my life easy I had create a small software do sign PDFs. You can see the softwawre on github: https://github.com/prfagun1/PDFSignatureTool Or for you that is not a developer just download de exe file and the background image here: Exe: Download Image: Download You can select the origin folder, the certificate and the place of the signature. After these click in Sign documents. Enjoy it.

Openedge (Progress) - List blocked users

You can use this select to list your blocked users and the user who is blocking the others. select  l."_Lock-Usr" as 'ID', l."_Lock-Name" as 'User', c."_Connect-IPAddress" as 'IP', l."_Lock-Flags" as 'Type 1', l."_Lock-Type" as ' Type 2', tb.TBL as 'Table', l."_Lock-RecId" as 'Register', database() as 'Database', c."_Connect-Pid" as 'PID OS', t."_Trans-Duration" as 'Time in seconds', ' Blocker ' as 'Status' from PUB."_Lock" l cross join sysprogress.SYSTABLES tb cross join pub."_connect" c left join pub."_trans" t on t."_Trans-Usrnum" = c."_Connect-Usr" join PUB."_Lock" l1 on l1."_Lock-Usr" is not null and l1."_Lock-Table" = l."_Lock-Table" and l1."_Lock-RecId" = l."_Lo...

MySQL - List table an index size

Use the select below to list information about tables and indexes in your MySQL database. SELECT COUNT(*) AS TotalTableCount ,table_schema ,CONCAT(ROUND(SUM(table_rows)/1000000,2),'M') AS TotalRowCount ,CONCAT(ROUND(SUM(data_length)/(1024*1024*1024),2),'G') AS TotalTableSize ,CONCAT(ROUND(SUM(index_length)/(1024*1024*1024),2),'G') AS TotalTableIndex ,CONCAT(ROUND(SUM(data_length+index_length)/(1024*1024*1024),2),'G') TotalSize         FROM information_schema.TABLES GROUP BY ENGINE ORDER BY SUM(data_length+index_length) DESC LIMIT 10;

Openedge (Progress) - BI reads and writes

You can see information about reads and writes on BI with the select below: SELECT database() as Database,                u."_UserIO-Name" as 'User',                u."_UserIO-BIRead" as 'Reads',                u."_UserIO-BiWrite" as 'Writes FROM PUB."_UserIO" u  where u."_UserIO-BiRead" > 0 or u."_UserIO-BiWrite" > 0  order by u."_UserIO-BiWrite" desc