You will need to play around with some damage systems, because Warcraft III won't let you get a unit's damage.
The first approach is with a damage system, such as LDD, or Anitarf's damage system. The second approach is to calculate damage statically, but checking all the items the unit has, upgrades, level and primary attribute.
For defense, I'm pretty sure there is a function for that somewhere around here. You just store the unit's HP, then damage it, then check how much HP it has based on the damage dealt, and the armor is the difference. (I think that's how it works).