Powershell import encoded module - powershell

I am writing a script with a lot of modules but I don't really want the user to see my source code so I figured to encode everything in base64 since the user won't be able to decode it even if it is that basic.
I tried to somehow add an encoded module but no luck.
So my question is -
Is it possible to import a base64 encoded module to the main script file?
If you have any better solutions to hide source code please share, I would be more than happy to try them out.
P.S. I tried to find some info on making a .dll files but found out I would have to rewrite the script in C#. (if I didn't missed anything)
Also I tried to put all modules into one encoded file, but then the file gets too big and Powershell is not able to process it anymore.

You've got two options, which can be combined if you would like to be extremely sure that no one will be able to access your code, making your code into an exe was already mentioned, there are several projects to do this but This one is nice as it is wholly contained within PS. The other, imo better, method is to use an obfuscator, which will take your code and replace variable names with nonsense strings and make other changes to make your code very difficult to read, it's still possible to work out your code but generally not worth the effort, you can find a working one Here. But I do have to add that obfuscating your code really goes against the powershell ethos and I recommend against doing it unless you have some sort of requirement too being passed down from management. And please note that this NOT an acceptable method of obscuring code that includes passwords, api keys, or any other information that needs to be secured as all of those are quite easy to extract from code that has been obfuscated this way.

You could change your ps1 to an exe file by using
https://ps2exe.codeplex.com/
You'd still be able to get at the code if you tried, but it would prevent a casual look.
Why do you want to hide the modules?

Related

Building an automated script to copy a page of text, translate it in Google Translator and paste it in Word

So, as the title says, I would like to make an automated script that is going to take all the text from one PDF page, copy it, paste it into Google Translate and then copy the translated text into another Microsoft Word document.
Since that PDF has a lot of pages (150+), I thought it may be easier to make an automated script to do that.
What language would I have to use, would it be complicated for me to do it and in the end, will I actually save time by using this script (implying that I have to learn it first, but I have some programming experience (I know C++, Javascript, PHP), but I do not have a strong grasp of algorithms (like Flood Fill, ...))?
Thanks in advance!
EDIT : I found that I could use AutoIt for scripting... but I don't know would I be better off using AutoIt or Powershell... I also want to learn something that would be enable me to create other scripts (for example to automate some processes I do in Camtasia Studio)... So, AutoIt or Powershell?
As an AutoIt user I would say AutoIt.
Copying text out of PDFs is not quite as simple as you might imagine. Mileage will vary on how the PDF was created, and there are several methods you can use:
Most PDFs will have most of the text in the file itself, allowing you to get the text using a simple method like this
This method uses zlib to do something to the pdf. Not sure what as I've never tried it.
There are a variety of examples of using third party programs to do this, which may be better. There is one using Debenu and another using XPDF
Automating other programs such as acrobat should be possible, in acrobats case they have an api that can be used, though I'm not aware of this already being wrapped in AutoIt.
As to the rest of the requirements, there is a UDF to translate with google translate here, and the word UDF is a standard one that comes with the AutoIt installation.

modify a template PDF using iTextSharp server side

So I'm brand spanking new to iTextSharp and I know I have quite a bit of reading ahead of me but in an attempt to shave a bunch of time off a relatively trivial task I thought I reach out the stack brain-trust.
I have a very simple goal: Starting with a template pdf, I need to create new pdf with a few of the characters changed. We're talking single characters on each page. I don't need a detailed answer complete with code (although that'd be awesome) so much as a general list of tools and api's I'm going to need.
The data I need will already be in a db which I could output to xml files if need be.
So far it looks like my template will need the "editable" characters tagged somehow (not sure how to do that yet) and using PDFStamper I can modify the copy. Is that the right path or is there a better way?
Thanks for any insight.

VB to download torrent, deflate gzipped section selectively

Apologies if this is a basic question, i'm a very casual programmer.
I'm writing a program which will search for torrents, grab them based on certain criteria (one being that they are indicated as freeware, you'll be pleased to hear) and then throw them over to utorrent. I'm getting stuck downloading the .torrent file, because, I believe, of the encoding.
I've worked out thus far that the bulk of the top of the file can be gzip deflated on the fly using HTTPrequest - but it seems that half-way through the file, something changes - and looking in a hex editor at a .torrent i've grabbed from a site directly versus the one I download here, everything is identical up to a point, then all is totally different.
If i'm being vague i'm afraid it's because i'm making this all up as I go along! Is it likely that the encoding / compression in a torrent file would change part way through, and how could I catch this in VB to avoid corrupting the latter half?
Thanks very much in advance,
Dan

perl excel to pdf

I'm using perl with an excel template to try to make creating invoices for clients somewhat automated. My only issue is that I'd really like to be able to convert this excel file to a PDF when I'm done, but I can't seem to find any perl modules that do anything of the sort. Anyone ever heard of something like this being done? I know it can be done somehow, since word and open office manage to do it!
Simply shell out to unoconv.
There are also Perl bindings to UNO, but last time I looked, they didn't work.
You may have to convert/flatten the Excel file first, and then figure out a way to pipe it in, but this may get you headed in the right direction http://metacpan.org/pod/PDF::Create

Anyone have file structure documentation for Windows Live Mail contacts.edb file?

Does anyone have any documentation or info on the file structure of the contacts.edb file as it is used in Windows Live Mail? I can't seem to find any way to import file back into WLM (I'm told it HAS no way, and must be "backed up" via manual exports to CSV files).
Given the apparent lack of means to reimport a backed up EDB file, I figured that perhaps I could just write a program to read all the contacts out into vcards or something, and then import those. (I'm actually looking ultimately to get them into Outlook, and ditch WLM for this user, cuz I don't feel like dealing with these maintenance headaches).
Problem is that I cannot find anywhere any information on the file format/structure for WLM's EDB files.
Thanks in advance, any help GREATLY appreciated!
To anyone finding this in the future, THIS CAN BE DONE, without needing to code anything! Use this program - EseDbViewer - to export the file to a CSV file, and then you can import that where ever you want.
Note that you pretty much need the whole file structure containing the edb, not just the edb file.
Hat-tip to #MicrosoftHelps on twitter.