Posts

Showing posts from April, 2022

Javascript for LibreOffice scripting

Image
Now, a js example to run in OO Calc: importClass(Packages.com.sun.star.uno.UnoRuntime); importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument); importClass(Packages.com.sun.star.container.XIndexAccess); importClass(Packages.com.sun.star.table.XCellRange); importClass(Packages.com.sun.star.table.XCell); documentRef = XSCRIPTCONTEXT.getDocument(); spreadsheetInterface = UnoRuntime.queryInterface(XSpreadsheetDocument, documentRef); allSheets = UnoRuntime.queryInterface(XIndexAccess, spreadsheetInterface.getSheets()); theSheet = allSheets.getByIndex(0); Cells = UnoRuntime.queryInterface(XCellRange,theSheet); cellA1 = Cells.getCellByPosition(0,0); theCell = UnoRuntime.queryInterface(XCell,cellA1); theCell.setFormula("Hello World"); // https://wiki.documentfoundation.org/images/f/f0/CG6212-CalcMacros.pdf   And here the result:  

VisualBasic scripting in LibreOffice

Image
 Here an example to run in Writer: Sub Hello Dim oDoc Dim sTextService$ Dim oCurs REM ThisComponent se refiere al documento actualmente activo oDoc = ThisComponent REM Verifica que este es un documento de texto sTextService = "com.sun.star.text.TextDocument" If NOT oDoc.supportsService(sTextService) Then MsgBox "This macro only works with a text document" Exit Sub End If REM obtiene la vista del cursor del controlador actual oCurs = oDoc.currentController.getViewCursor() REM Mueve el cursor al final del documento oCurs.gotoEnd(False) REM Inserta el texto “Hola” al final del documento oCurs.Text.insertString(oCurs, "Hello World", False) End Sub REM https://documentation.libreoffice.org/assets/Uploads/Documentation/es/GS52/PDF/GS5213-PrimerosPasosConMacros.pdf And the result is here:

BeanShell scripting in LibreOffice

Image
Here is a BeanShell script to xploit functionalities from LibreOffice spreadsheeat: import com.sun.star.uno.UnoRuntime; import com.sun.star.sheet.XSpreadsheetView; import com.sun.star.text.XText; import com.sun.star.sheet.XCellRangeData; // // Get active spreadsheet // model = XSCRIPTCONTEXT.getDocument(); controller = model.getCurrentController(); view = UnoRuntime.queryInterface(XSpreadsheetView.class, controller); sheet = view.getActiveSheet(); // // Create a TEXT CELL // // Get cell by position cell = sheet.getCellByPosition(0, 0); // Access the cell text cellText = UnoRuntime.queryInterface(XText.class, cell); // Get the text cursor of the cell text textCursor = cellText.createTextCursor(); // Insert a string in the cell through the text cursor and overwrite the cell content // Using 'false' as third parameter adds the inserted string cellText.insertString(textCursor, "BeanShell macro example", true); // // Access and modify VALUE CELLS // // Get cell by position

[Solved] Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

 If you run apt update, you probably will see the following message: [Solved] Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details. To solve it, you need to export the GPG key from the deprecated keyring and store it in /usr/share/keyrings. To do it, just get the last 4 bytes from the fingerprint and export the key to /usr/share/keyrings folder: sudo apt-key list Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). /etc/apt/trusted.gpg -------------------- pub   rsa4096 2018-08-14 [SC]       E869 7E2E EF76 C02D 3A63  3277 8881 B2A8 2109 76F2 uid           [ unknown] Package Manager (Package Signing Key) <packages@pgadmin.org> sub   rsa4096 2018-08-14 [E]  sudo apt-key export 210976F2 | sudo gpg --dearmour -o /usr/share/keyrings/pgadmin4.gpg   Now, you need to update the apt source file and add a signed-by tag between deb and the url: sudo vim /etc/apt/sources.list.d/pg

[Solved] Install scapy on Ubuntu 22.04

 If you try to install scapy from apt, you will see the following issues: sudo apt install python3-scapy sudo scapy <frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module() <frozen importlib._bootstrap>:671: ImportWarning: _SixMetaPathImporter.exec_module() not found; falling back to load_module() INFO: Can't import PyX. Won't be able to use psdump() or pdfdump(). To solve them, you need pyx module sudo apt install python3-pyx I could not find info about _SixMetaPathImporter.exec_module()  To avoid this warning, just install the git version: git clone https://github.com/secdev/scapy.git cd scapy sudo python3 setup.py install Enjoy it!

[Solved] Install SAP GUI 7.70 patch level 5 (18/02/2022) Java in Ubuntu 22.04

Image
 First, you need to install the dependencies: apt-get update sudo bash apt-get install -y --no-install-recommends wget ca-certificates gnupg2 export GNUPGHOME="$(mktemp -d)" wget -q -O - https://dist.sapmachine.io/debian/sapmachine.old.key | gpg --batch --import gpg --batch --export --armor 'DA4C 00C1 BDB1 3763 8608 4E20 C7EB 4578 740A EEA2' > /etc/apt/trusted.gpg.d/sapmachine.old.gpg.asc wget -q -O - https://dist.sapmachine.io/debian/sapmachine.key | gpg --batch --import gpg --batch --export --armor 'CACB 9FE0 9150 307D 1D22 D829 6275 4C3B 3ABC FE23' > /etc/apt/trusted.gpg.d/sapmachine.gpg.asc gpgconf --kill all && rm -rf "$GNUPGHOME" echo "deb http://dist.sapmachine.io/debian/amd64/ ./" > /etc/apt/sources.list.d/sapmachine.list apt-get update apt-get install sapmachine-18-jdk openjfx Next, download SAP GUI 7.70 from mediafire Execute the jar file with the following sentence: sudo java -jar PlatinGUI770_5-80004696.JAR Next

[Solved] How to install VMPlayer on Ubuntu 22.04

Image
First, download it from the official url Now, change the permissions to execute it: chmod +x VMware-Player-Full-16.2.3-19376536.x86_64.bundle sudo ./VMware-Player-Full-16.2.3-19376536.x86_64.bundle Now, you need to run VMPlayer, but you probably see the following issue:       To install all modules in newer kernels, just install  this package: wget https://codeload.github.com/mkubecek/vmware-host-modules/tar.gz/refs/heads/workstation-16.2.1 -O workstation-16.2.1.tar.gz tar xvf workstation-16.2.1.tar.gz cd vmware-host-modules-workstation-16.2.1/ make sudo make install   If you try to run an image, you could see the following alert: This means you need to load the vmmon and vmnet modules to the kernel: sudo modprobe vmmon sudo modprobe vmnet   Now, you could run VMPlayer without issues!