# AWS - MSK Enum {{#include ../../../banners/hacktricks-training.md}} ## Amazon MSK **Amazon Managed Streaming for Apache Kafka (Amazon MSK)** is 'n diens wat ten volle bestuur word, wat die ontwikkeling en uitvoering van toepassings wat stroomdata verwerk deur **Apache Kafka** fasiliteer. Beheer-vlak operasies, insluitend die skep, opdateer en verwyder van **clusters**, word deur Amazon MSK aangebied. Die diens laat die gebruik van Apache Kafka **data-vlak operasies** toe, wat data produksie en verbruik insluit. Dit werk op **oop-bron weergawes van Apache Kafka**, wat verseker dat dit versoenbaar is met bestaande toepassings, gereedskap en plugins van beide vennote en die **Apache Kafka-gemeenskap**, wat die behoefte aan veranderinge in die toepassingskode uitskakel. In terme van betroubaarheid, is Amazon MSK ontwerp om **outomaties te detecteer en te herstel van algemene cluster-faal scenario's**, wat verseker dat produsent- en verbruiker-toepassings voortgaan met hul data skryf- en leesaktiwiteite met minimale onderbreking. Boonop poog dit om data replikasie prosesse te optimaliseer deur te probeer om die **berging van vervangde brokers** te **hergebruik**, wat die volume van data wat deur Apache Kafka gerepliseer moet word, minimaliseer. ### **Tipes** Daar is 2 tipes Kafka clusters wat AWS toelaat om te skep: Provisioned en Serverless. Van die oogpunt van 'n aanvaller moet jy weet dat: - **Serverless kan nie direk publiek wees nie** (dit kan slegs in 'n VPN loop sonder enige publiek blootgestelde IP). egter, **Provisioned** kan gekonfigureer word om 'n **publieke IP** te kry (per standaard doen dit nie) en die **veiligheidsgroep** te konfigureer om die relevante poorte te **bloot te stel**. - **Serverless** **ondersteun slegs IAM** as autentikasie metode. **Provisioned** ondersteun SASL/SCRAM (**wagwoord**) autentikasie, **IAM** autentikasie, AWS **Certificate** Manager (ACM) autentikasie en **Onautentiseerde** toegang. - Let daarop dat dit nie moontlik is om 'n Provisioned Kafka publiek bloot te stel as onaudentiseerde toegang geaktiveer is nie. ### Enumeration ```bash #Get clusters aws kafka list-clusters aws kafka list-clusters-v2 # Check the supported authentication aws kafka list-clusters | jq -r ".ClusterInfoList[].ClientAuthentication" # Get Zookeeper endpoints aws kafka list-clusters | jq -r ".ClusterInfoList[].ZookeeperConnectString, .ClusterInfoList[].ZookeeperConnectStringTls" # Get nodes and node enspoints aws kafka kafka list-nodes --cluster-arn aws kafka kafka list-nodes --cluster-arn | jq -r ".NodeInfoList[].BrokerNodeInfo.Endpoints" # Get endpoints # Get used kafka configs aws kafka list-configurations #Get Kafka config file aws kafka describe-configuration --arn # Get version of config aws kafka describe-configuration-revision --arn --revision # Get content of config version # If using SCRAN authentication, get used AWS secret name (not secret value) aws kafka list-scram-secrets --cluster-arn ``` ### Kafka IAM Toegang (in serverless) ```bash # Guide from https://docs.aws.amazon.com/msk/latest/developerguide/create-serverless-cluster.html # Download Kafka wget https://archive.apache.org/dist/kafka/2.8.1/kafka_2.12-2.8.1.tgz tar -xzf kafka_2.12-2.8.1.tgz # In kafka_2.12-2.8.1/libs download the MSK IAM JAR file. cd kafka_2.12-2.8.1/libs wget https://github.com/aws/aws-msk-iam-auth/releases/download/v1.1.1/aws-msk-iam-auth-1.1.1-all.jar # Create file client.properties in kafka_2.12-2.8.1/bin security.protocol=SASL_SSL sasl.mechanism=AWS_MSK_IAM sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required; sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler # Export endpoints address export BS=boot-ok2ngypz.c2.kafka-serverless.us-east-1.amazonaws.com:9098 ## Make sure you will be able to access the port 9098 from the EC2 instance (check VPS, subnets and SG) # Create a topic called msk-serverless-tutorial kafka_2.12-2.8.1/bin/kafka-topics.sh --bootstrap-server $BS --command-config client.properties --create --topic msk-serverless-tutorial --partitions 6 # Send message of every new line kafka_2.12-2.8.1/bin/kafka-console-producer.sh --broker-list $BS --producer.config client.properties --topic msk-serverless-tutorial # Read messages kafka_2.12-2.8.1/bin/kafka-console-consumer.sh --bootstrap-server $BS --consumer.config client.properties --topic msk-serverless-tutorial --from-beginning ``` ### Privesc {{#ref}} ../aws-privilege-escalation/aws-msk-privesc.md {{#endref}} ### Unauthenticated Access {{#ref}} ../aws-unauthenticated-enum-access/aws-msk-unauthenticated-enum.md {{#endref}} ### Persistence As jy **toegang tot die VPC** waar 'n Provisioned Kafka is, gaan hĂȘ, kan jy **nie-geautoriseerde toegang** **aktiveer**, as **SASL/SCRAM-oute** gebruik word, **lees** die wagwoord uit die geheim, gee 'n paar **ander beheerde gebruiker IAM-toestemmings** (as IAM of serverless gebruik word) of volhard met **sertifikate**. ## References - [https://docs.aws.amazon.com/msk/latest/developerguide/what-is-msk.html](https://docs.aws.amazon.com/msk/latest/developerguide/what-is-msk.html) {{#include ../../../banners/hacktricks-training.md}}