We tested out the basics of a macro within Excel and learned that we can
actually go through and use a little bit of coding techniques such as Visual
Basic and C++ which is what I'm familiar with.
To go through and program our macros to do certain things that generally would
be of use for us.
We're going to walk our way through how we can make a button or a couple of
objects and incorporate those macros inside of our actual spreadsheet and
possibly other office applications.
Let's take a look on the side screen as you can see my VMware environment and I
will increase the size on this for us because we're going to stay inside of
Windows for just a minute.
There we go.
Now as you can see here I'm working on a budget and this budget is pretty
simple.
I have rent, I have a truck note, insurance and always a nice spiffy flannel
expense.
And this is every month and instead of adding everything all together or trying
to do formatting of the cells and the functions that carry within.
I want to be able to make this easy on myself by just clicking a button and
having to go and this button is going to program to add all four of those cells
together and give me a total of my expenses every month.
Now in order to do this we need to make sure that we have the developer tab
available to us again file options check your menus and make sure things are
checked that need to be.
And inside of here you'll notice that there is an insert option for us. Now you
can drop this insert down and.
You can see in here there are different options check boxes scroll wheels, but
the one on the top left is the button.
And as soon as we click on it we can draw where we want our button and it's
automatically going to open up.
Or assign macro window that's going to say hey what do you want to assign to
this particular object because the button itself needs to have a function
otherwise it's just there for a nice team.
Now you may like those little buttons and I like clicking things too, but I
actually want this to do something.
And as you can see I'm going to zoom in for us real quick that we already have
our test macro that we did earlier that's already above a code and file.
And we have our button click one and button click to was the one I just drew I
'm going to cancel that one and show you inside of button click number one.
And well there's that button that doesn't do anything we're going to go ahead
delete that.
And inside of button click one if you can't find it or you're a little bit lost
after you create it by accident like I did.
Go to the macro tab on the top left just click on macros again and you'll see
it in there as button one underscore click.
I'm going to cancel that and I'm actually going to go to our macro editor and
there's a couple of things I want to point out here real quick.
As we zoom in you can see that we have both of our macros in there separated by
a line divider because we have subtest.
The function for that and that's that first macro that we created we didn't
assign it to anything we just developed it to see what we can actually do and
in that one we ran no pad.exe.
And right below that you see the sub function of button one underscore click
now there's a particular learner out there that I know personally and I just
want to say that this is a procedure.
I hope you get that reference.
But inside of this is where you can see I put the programming code in here for
basically just doing a sum of all the cells that have values in them for my
monthly expenses.
And then I have a range be nine which is that cell that's going to have the
value equal to all the cells added up that is the variable of some result.
Now that's the program that's run in there and is going to be assigned to that
macro now I've already saved it and again I'll have the code for this and the
actual file for you here in just a second.
I can go even further and run it in here with the play pause or stop button but
I want to show you what it looks like inside of Excel.
Let's go back to Excel real quick and I'm going to go ahead and press the
button and as you can see there boom check a lot in B9 it assigned $1,725.
And zero cents for my monthly expenses.
Well that's pretty good and if I go back in and change some of the values.
Let's say $100 for flannel you'll notice that B9 did not automatically update
and that's because we didn't do our cell formula.
I got to click the button again to recalculate and in this particular case
actually cleared the cell out because there's a function in program you could
put in there to actually clear that cell and I'm going to hit the button again
and it's going to.
Yep there we go fill it back in with a.
Value now I'm not worried about whether that number equals out to the correct
value or not. I'm not here to make an actual spreadsheet of calculations.
What I'm here to do is make a macro that could be manipulated and if we go back
into the macro editor itself what we're going to do is we're going to copy our
notepad.
Opening and bring it down to our sub function slash procedure of button one
click now I'm going to go ahead and paste it in here and as you can see now I'm
going to hit enter and then I'm going to go hit save.
Warning from Microsoft duly noted we're going to save anyway.
And as I pop out and zoom in you can see here that now my button plate does two
things when it does the value of some results for all those cells and it
includes the notepad.exe shell command.
So when I press this button what I should get is a cell filling of a value and
a notepad.
Opening up to test this we're going to go back over to our Excel spreadsheet
clear out that one cell that already has a value in it and press a button and
notice that notepad just opened up.
I'm going to go ahead and close notepad and then you could also see here is a
zoom in for you that B nine has been populated with a number of currency.
Again not worried about the addition of this I'm just pointing out that it did
two things at once.
And you what you may have also noticed too is something very important to a
cybersecurity professionals.
But default macros are allowed inside of Microsoft Office applications.
And we always take the precaution as secure security technicians and
administrators to go through and try to disable macro usage inside of Microsoft
Office and other macro related applications.
The reason for this is because we just invoked a program from the actual shell
of the operating system along with masking it with a function that is useful to
that actual spreadsheet.
And this invites people to be able to create their own lines of code and hide
them as macros and bury them inside of the actual word document or Microsoft
Office document to send to unsuspecting folks to be able to do.
The various things we're going to be covering the various things in the next
portion of the skill as we start to dive in and show some backdoor stuff be
right back.