You can't use msfpayload and msfencode in msfconsole. You have the following options:
1. Use mfscli in combination with msfpayload and msfencode like you alraedy did and published in the book.
2. Use msfvenom
Usage: /opt/framework/msf3/msfvenom [options] <var=val>
-p, --payload [payload] Payload to use. Specify a '-' or stdin to use custom payloads
-l, --list [module_type] List a module type example: payloads, encoders, nops, all
-n, --nopsled [length] Prepend a nopsled of [length] size on to the payload
-f, --format [format] Format to output results in: raw, ruby, rb, perl, pl, bash, sh, c, js_be, js_le, java, dll, exe, exe-small, elf, macho, vba, vbs, loop-vbs, asp, war
-e, --encoder [encoder] The encoder to use
-a, --arch [architecture] The architecture to use
The platform of the payload
-s, --space [length] The maximum size of the resulting payload
-b, --bad-chars [list] The list of characters to avoid example: '\x00\xff'
-i, --iterations [count] The number of times to encode the payload
-c, --add-code [path] Specify an additional win32 shellcode file to include
-x, --template [path] Specify a custom executable file to use as a template
-k, --keep Preserve the template behavior and inject the payload as a new thread
-h, --help Show this message
thank you! i will give it a try
I wanted to post an article that I feel is relevant to evading Antivirus with metasploit payloads. This method offers alot of flexibility to the penetration testers to obfuscate the ASM instructions however they chose. For more information see this blog article here:
Let me know your thoughts!